feat:完善项目信息

This commit is contained in:
henry
2022-01-19 14:22:44 +08:00
parent 61d345b571
commit 417d7961ec
9 changed files with 128 additions and 25 deletions

View File

@ -40,10 +40,6 @@ type (
Researchs []string `json:"researchs"`
Area string `json:"area"`
}
// ExpertParams 专家参数信息
ExpertParams struct {
ID, TenantID uint64
}
)
// Instance 首页信息
@ -89,7 +85,7 @@ func (c *Expert) Instance(tenantID uint64, name string, examineStatus int, page,
}
// Detail 详细信息
func (*Expert) Detail(id uint64) (*ExpertDetail, error) {
func (c *Expert) Detail(id uint64) (*ExpertDetail, error) {
mManageExpert := model.NewManageExpert()
out, err := mManageExpert.Expert(id)
@ -110,27 +106,42 @@ func (*Expert) Detail(id uint64) (*ExpertDetail, error) {
}
// Form 数据操作
func (*Expert) Form(params *BasicParams, other *config.IdentityForExpert) error {
func (c *Expert) Form(params *BasicParams, other *config.IdentityForExpert) error {
mManageExpert := model.NewManageExpert()
if params.ID > 0 {
mManageExpert.ID = params.ID
isExist, err := model2.FirstField(mManageExpert.ManageExpert, []string{"id", "examine_status", "created_at"})
isExist, err := model2.FirstField(mManageExpert.ManageExpert, []string{"id", "name", "mobile", "tenant_id", "created_at"})
if err != nil {
return err
} else if !isExist {
return errors.New("操作错误,专家信息不存在或已被删除")
}
if c.TenantID > 0 {
if mManageExpert.TenantID != c.TenantID {
return errors.New("操作错误,无权限操作")
}
} else {
if mManageExpert.TenantID != params.TenantID {
if isExist, err = params.isExist(mManageExpert.ManageExpert, model2.NewWhere("tenant_id", params.TenantID),
model2.NewWhere("mobile", params.Mobile)); err != nil {
return err
} else if isExist {
return errors.New("操作错误,当前站点下已存在相同手机号码")
}
}
}
}
mManageExpert.TenantID = params.TenantID
mManageExpert.TenantID = c.TenantID
mManageExpert.ResearchID = other.ConvertResearch()
mManageExpert.LaboratoryID = other.ConvertLaboratory()
mManageExpert.Image.Image = params.Image
mManageExpert.Area = model2.Area{
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
}
mManageExpert.Education = other.Education
mManageExpert.School = other.School
mManageExpert.Major = other.Major
mManageExpert.Job = other.Job
@ -142,12 +153,22 @@ func (*Expert) Form(params *BasicParams, other *config.IdentityForExpert) error
mManageExpert.SetResearchAttribute(other.Researchs)
mManageExpert.Introduce = params.Introduce
if c.TenantID <= 0 {
mManageExpert.TenantID = params.TenantID
}
if mManageExpert.ID > 0 {
return model2.Updates(mManageExpert.ManageExpert, mManageExpert.ManageExpert)
}
// 查询手机号码是否在当前租户下是否已经注册了
mManageExpert.Name = params.Name
mManageExpert.Mobile = params.Mobile
if isExist, err := params.isExist(mManageExpert.ManageExpert, model2.NewWhere("tenant_id", params.TenantID),
model2.NewWhere("mobile", params.Mobile)); err != nil {
return err
} else if isExist {
return errors.New("操作错误,当前站点下已存在相同手机号码")
}
return model2.Create(mManageExpert.ManageExpert)
}