feat:完善信息
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/enterprise/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
)
|
||||
|
||||
@ -19,9 +20,12 @@ type SettledParams struct {
|
||||
Name string // 名称
|
||||
Code string // 唯一编码
|
||||
config.Area
|
||||
Introduce string `json:"introduce"`
|
||||
Introduce string
|
||||
Industry uint64 `json:"industry"`
|
||||
Keywords []string `json:"keywords"`
|
||||
}
|
||||
|
||||
// effect 入驻信息有效性
|
||||
func (c *SettledParams) effect(uid uint64, iModel model2.IModel) error {
|
||||
if c.ID <= 0 {
|
||||
var count int64
|
||||
@ -41,6 +45,14 @@ func (c *SettledParams) effect(uid uint64, iModel model2.IModel) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// pass 入驻信息通过性
|
||||
func (c *SettledParams) pass(uid, mUID uint64, mStatus model2.ExamineStatusKind) bool {
|
||||
if mUID != uid || mStatus != model2.ExamineStatusForRefuse {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Company 公司企业
|
||||
func (c *Settled) Company(params *SettledParams, other *config.IdentityForCompany) error {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
@ -56,34 +68,115 @@ func (c *Settled) Company(params *SettledParams, other *config.IdentityForCompan
|
||||
mManageCompany.Area = model2.Area{
|
||||
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
}
|
||||
mManageCompany.Industry = other.Industry
|
||||
mManageCompany.SetKeywordAttribute(other.Keywords)
|
||||
mManageCompany.Industry = params.Industry
|
||||
mManageCompany.SetKeywordAttribute(params.Keywords)
|
||||
mManageCompany.Introduce = params.Introduce
|
||||
|
||||
if mManageCompany.ID <= 0 {
|
||||
mManageCompany.UID = c.UID
|
||||
return model2.Create(mManageCompany.ManageCompany)
|
||||
}
|
||||
if mManageCompany.UID != c.UID {
|
||||
return errors.New("异常,无权限操作")
|
||||
} else if mManageCompany.Status != model2.ExamineStatusForRefuse {
|
||||
return errors.New("操作错误,不允许操作")
|
||||
if !params.pass(c.UID, mManageCompany.UID, mManageCompany.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageCompany.Status = model2.ExamineStatusForOngoing
|
||||
return model2.Updates(mManageCompany.ManageCompany, mManageCompany.ManageCompany)
|
||||
}
|
||||
|
||||
// Expert 专家
|
||||
func (c *Settled) Expert() {
|
||||
func (c *Settled) Expert(params *SettledParams, other *config.IdentityForExpert) error {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
|
||||
err := params.effect(c.UID, mManageExpert.ManageExpert)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mManageExpert.TenantID = other.TenantID
|
||||
mManageExpert.Area = model2.Area{
|
||||
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
}
|
||||
mManageExpert.Industry = params.Industry
|
||||
mManageExpert.SetKeywordAttribute(params.Keywords)
|
||||
mManageExpert.Introduce = params.Introduce
|
||||
mManageExpert.Position = utils.AnyToJSON(model2.Position{Longitude: other.Longitude, Latitude: other.Latitude})
|
||||
mManageExpert.School = other.School
|
||||
mManageExpert.Major = other.Major
|
||||
mManageExpert.Job = other.Job
|
||||
mManageExpert.Title = other.Title
|
||||
mManageExpert.WorkAt = utils.DataTimeToDate(other.WorkAt)
|
||||
mManageExpert.Research = utils.AnyToJSON(other.Research)
|
||||
|
||||
if mManageExpert.ID <= 0 {
|
||||
mManageExpert.UID = c.UID
|
||||
return model2.Create(mManageExpert.ManageExpert)
|
||||
}
|
||||
if !params.pass(c.UID, mManageExpert.UID, mManageExpert.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageExpert.Status = model2.ExamineStatusForOngoing
|
||||
return model2.Updates(mManageExpert.ManageExpert, mManageExpert.ManageExpert)
|
||||
}
|
||||
|
||||
// Research 研究机构
|
||||
func (c *Settled) Research() {
|
||||
func (c *Settled) Research(params *SettledParams, other *config.IdentityForResearch) error {
|
||||
mManageResearch := model.NewManageResearch()
|
||||
|
||||
err := params.effect(c.UID, mManageResearch.ManageResearch)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mManageResearch.Area = model2.Area{
|
||||
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
}
|
||||
mManageResearch.Industry = params.Industry
|
||||
mManageResearch.SetKeywordAttribute(params.Keywords)
|
||||
mManageResearch.Introduce = params.Introduce
|
||||
mManageResearch.Position = utils.AnyToJSON(model2.Position{Longitude: other.Longitude, Latitude: other.Latitude})
|
||||
mManageResearch.Research = other.Research
|
||||
|
||||
if mManageResearch.ID <= 0 {
|
||||
mManageResearch.UID = c.UID
|
||||
return model2.Create(mManageResearch.ManageResearch)
|
||||
}
|
||||
if !params.pass(c.UID, mManageResearch.UID, mManageResearch.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageResearch.Status = model2.ExamineStatusForOngoing
|
||||
return model2.Updates(mManageResearch.ManageResearch, mManageResearch.ManageResearch)
|
||||
}
|
||||
|
||||
// Laboratory 实验室
|
||||
func (c *Settled) Laboratory() {
|
||||
func (c *Settled) Laboratory(params *SettledParams, other *config.IdentityForLaboratory) error {
|
||||
mManageLaboratory := model.NewManageLaboratory()
|
||||
|
||||
err := params.effect(c.UID, mManageLaboratory.ManageLaboratory)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mManageLaboratory.TenantID = other.TenantID
|
||||
mManageLaboratory.Name = params.Name
|
||||
mManageLaboratory.Code = params.Code
|
||||
mManageLaboratory.Area = model2.Area{
|
||||
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
}
|
||||
mManageLaboratory.Industry = params.Industry
|
||||
mManageLaboratory.SetKeywordAttribute(params.Keywords)
|
||||
mManageLaboratory.Introduce = params.Introduce
|
||||
mManageLaboratory.Position = utils.AnyToJSON(model2.Position{Longitude: other.Longitude, Latitude: other.Latitude})
|
||||
mManageLaboratory.Research = utils.AnyToJSON(other.Research)
|
||||
|
||||
if mManageLaboratory.ID <= 0 {
|
||||
mManageLaboratory.UID = c.UID
|
||||
return model2.Create(mManageLaboratory.ManageLaboratory)
|
||||
}
|
||||
if !params.pass(c.UID, mManageLaboratory.UID, mManageLaboratory.Status) {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
mManageLaboratory.Status = model2.ExamineStatusForOngoing
|
||||
return model2.Updates(mManageLaboratory.ManageLaboratory, mManageLaboratory.ManageLaboratory)
|
||||
}
|
||||
|
||||
// Agent 经纪人
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"SciencesServer/app/service"
|
||||
config2 "SciencesServer/config"
|
||||
"SciencesServer/serve/orm"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
@ -18,11 +17,10 @@ type Tenant struct{ *service.SessionEnterprise }
|
||||
type TenantHandle func(session *service.SessionEnterprise) *Tenant
|
||||
|
||||
type TenantBasicParams struct {
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
Name string `json:"name"` // 名称
|
||||
Email string `json:"email"` // 邮箱
|
||||
Job string `json:"job"` // 职务
|
||||
Address string `json:"address"` // 详细地址
|
||||
Name string `json:"name"` // 名称
|
||||
Email string `json:"email"` // 邮箱
|
||||
Job string `json:"job"` // 职务
|
||||
FixedPhone string `json:"fixed_phone"` // 固定电话
|
||||
}
|
||||
|
||||
type TenantIndustryParams struct {
|
||||
@ -31,38 +29,35 @@ type TenantIndustryParams struct {
|
||||
type (
|
||||
// TenantPerfectParams 完善信息参数
|
||||
TenantPerfectParams struct {
|
||||
*TenantBasicParams // 基本信息
|
||||
*TenantParamsForCompany // 公司身份信息
|
||||
*TenantBasicParams // 基本信息
|
||||
}
|
||||
// TenantParamsForCompany 公司参数信息
|
||||
TenantParamsForCompany struct {
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
config.Area
|
||||
model2.Position
|
||||
Industry string `json:"industry"`
|
||||
Introduce string `json:"introduce"`
|
||||
}
|
||||
)
|
||||
|
||||
// tenantHandlePerfect 完善信息处理方式
|
||||
var tenantHandlePerfect = map[int]func(params *TenantPerfectParams) (string, error){
|
||||
config.TenantUserIdentityForCompany: perfectForCompany,
|
||||
config.TenantUserIdentityForExpert: perfectForExpert,
|
||||
config.TenantUserIdentityForCompany: perfectForCompany,
|
||||
config.TenantUserIdentityForExpert: perfectForExpert,
|
||||
config.TenantUserIdentityForResearch: perfectForResearch,
|
||||
config.TenantUserIdentityForLaboratory: perfectForLaboratory,
|
||||
}
|
||||
|
||||
func perfectForCompany(params *TenantPerfectParams) (string, error) {
|
||||
if params.TenantParamsForCompany == nil {
|
||||
return "", errors.New("企业信息异常")
|
||||
}
|
||||
return utils.AnyToJSON(params.TenantParamsForCompany), nil
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func perfectForExpert(params *TenantPerfectParams) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func perfectForResearch() error {
|
||||
return nil
|
||||
func perfectForResearch(params *TenantPerfectParams) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func perfectForLaboratory(params *TenantPerfectParams) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// Perfect 完善信息
|
||||
@ -76,48 +71,25 @@ func (c *Tenant) Perfect(params *TenantPerfectParams) error {
|
||||
// 查询用户身份信息
|
||||
mUserTenant := model.NewUserTenant()
|
||||
|
||||
isExist, err := model2.FirstField(mUserTenant.UserTenant, []string{"id", "name", "identity", "status"},
|
||||
isExist, err := model2.FirstField(mUserTenant.UserTenant, []string{"id", "name", "identity"},
|
||||
model2.NewWhere("uid", c.UID), model2.NewWhere("identity", c.Identity))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
if mUserTenant.Status != model2.UserTenantStatusForExamining {
|
||||
return errors.New("资料审核中,不可修改")
|
||||
} else if mUserTenant.Status != model2.UserTenantStatusForExaminePass {
|
||||
return errors.New("资料审核已通过,不可修改")
|
||||
}
|
||||
}
|
||||
mUserTenant.Avatar = params.TenantBasicParams.Avatar
|
||||
mUserTenant.Name = params.TenantBasicParams.Name
|
||||
mUserTenant.Email = params.TenantBasicParams.Email
|
||||
mUserTenant.Identity = c.SelectIdentity
|
||||
mUserTenant.Address = params.TenantBasicParams.Address
|
||||
mUserTenant.Job = params.TenantBasicParams.Job
|
||||
mUserTenant.FixedPhone = params.TenantBasicParams.FixedPhone
|
||||
|
||||
if mUserTenant.Other, err = _handle(params); err != nil {
|
||||
return err
|
||||
}
|
||||
mUserTenant.Status = model2.UserTenantStatusForExamining
|
||||
|
||||
if isExist {
|
||||
if err = model2.Updates(mUserTenant.UserTenant, mUserTenant.UserTenant); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
if !isExist {
|
||||
mUserTenant.Identity = c.SelectIdentity
|
||||
return model2.Create(mUserTenant.UserTenant)
|
||||
}
|
||||
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.Updates(mUserTenant.UserTenant, map[string]interface{}{
|
||||
"selected": model2.UserTenantSelectedForNo, "updated_at": time.Now(),
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
mUserTenant.Selected = model2.UserTenantSelectedForYes
|
||||
|
||||
return model2.Create(mUserTenant.UserTenant, tx)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return model2.Updates(mUserTenant.UserTenant, mUserTenant.UserTenant)
|
||||
}
|
||||
|
||||
// Auth 认证
|
||||
|
Reference in New Issue
Block a user