feat:完善项目信息
This commit is contained in:
@ -2,6 +2,7 @@ package manage
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
@ -75,8 +76,64 @@ func (c *Company) Instance(tenantID uint64, name string, status int, page, pageS
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
func (c *Company) Form(params *CompanyParams) error {
|
||||
return nil
|
||||
func (c *Company) Form(params *BasicParams, other *config.IdentityForCompany) error {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
// 查询相应的企业入驻信息
|
||||
if params.ID > 0 {
|
||||
mManageCompany.ID = params.ID
|
||||
|
||||
isExist, err := model2.FirstField(mManageCompany.ManageCompany, []string{"id", "name", "code", "tenant_id", "created_at"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,公司企业信息不存在或已被删除")
|
||||
}
|
||||
if c.TenantID > 0 {
|
||||
if mManageCompany.TenantID != c.TenantID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
} else {
|
||||
if mManageCompany.TenantID != params.TenantID {
|
||||
if isExist, err = params.isExist(mManageCompany.ManageCompany, model2.NewWhere("tenant_id", params.TenantID),
|
||||
model2.NewWhere("code", params.Code)); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前站点下已存在同一公司组织机构代码")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mManageCompany.TenantID = c.TenantID
|
||||
mManageCompany.Image = model2.Image{Image: params.Image}
|
||||
mManageCompany.Area = model2.Area{
|
||||
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
}
|
||||
mManageCompany.Product = other.Product
|
||||
mManageCompany.Url = other.Url
|
||||
mManageCompany.License = other.License
|
||||
mManageCompany.SetIndustryAttribute(params.Industrys)
|
||||
mManageCompany.SetKeywordAttribute(params.Keywords)
|
||||
mManageCompany.SetDirectionAttribute(other.Directions)
|
||||
mManageCompany.Introduce = params.Introduce
|
||||
|
||||
if c.TenantID <= 0 {
|
||||
mManageCompany.TenantID = params.TenantID
|
||||
}
|
||||
if mManageCompany.ID > 0 {
|
||||
return model2.Updates(mManageCompany.ManageCompany, mManageCompany.ManageCompany)
|
||||
}
|
||||
// 查询手机号码是否在当前租户下是否已经注册了
|
||||
mManageCompany.Name = params.Name
|
||||
mManageCompany.Code = params.Code
|
||||
|
||||
if isExist, err := params.isExist(mManageCompany.ManageCompany, model2.NewWhere("tenant_id", params.TenantID),
|
||||
model2.NewWhere("code", params.Code)); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前站点下已存在同一公司组织机构代码")
|
||||
}
|
||||
return model2.Create(mManageCompany.ManageCompany)
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
|
Reference in New Issue
Block a user