You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
package logic
|
|
|
|
import (
|
|
"errors"
|
|
"github.com/jinzhu/gorm"
|
|
"recook/internal/model/vend"
|
|
"recook/tools"
|
|
)
|
|
|
|
type Sector struct {
|
|
Name string `json:"name" form:"name"` // 姓名
|
|
Phone string `json:"phone" form:"phone"` // 手机号
|
|
Email string `json:"email" form:"email"` // 邮箱
|
|
Position string `json:"position" form:"position"` // 邮箱
|
|
}
|
|
type sector struct {
|
|
}
|
|
|
|
var SectorLogic = §or{}
|
|
|
|
// @Style 联系人验证
|
|
func (s *sector) VerfiySector(liaison Sector) error {
|
|
if liaison.Name == "" {
|
|
return errors.New("请填写联系人姓名")
|
|
}
|
|
if liaison.Phone == "" {
|
|
return errors.New("部门联系人手机号格式错误")
|
|
}
|
|
if !tools.VerifyEmail(liaison.Email) {
|
|
return errors.New("联系人邮箱格式错误")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// @Style 添加联系人
|
|
func (s *sector) Create(data *vend.GysEnterpriseSector, db *gorm.DB) {
|
|
db.Create(data)
|
|
}
|
|
|
|
// @Style
|
|
func (s *sector) Delete(enterpriseId uint, db *gorm.DB) int64 {
|
|
return db.Where("enterprise_id = ?", enterpriseId).Delete(&vend.GysEnterpriseSector{}).RowsAffected
|
|
}
|