feat:完善入驻信息管理
This commit is contained in:
@ -31,8 +31,8 @@ func (c *RegisterParams) checkCaptcha() (bool, error) {
|
||||
func (c *RegisterParams) checkUserExist(mUserInstance *model2.UserInstance, local string) (bool, error) {
|
||||
var count int64
|
||||
|
||||
if err := model2.Count(mUserInstance, &count, model2.NewWhere("mobile", c.Mobile),
|
||||
model2.NewWhere("local", local)); err != nil {
|
||||
if err := model2.Count(mUserInstance, &count, model2.NewWhere("mobile", c.Mobile)); //model2.NewWhere("local", local)
|
||||
err != nil {
|
||||
return false, err
|
||||
}
|
||||
return count <= 0, nil
|
||||
@ -60,7 +60,6 @@ func (c *Register) Launch(params *RegisterParams) (*InstanceLoginReturn, error)
|
||||
} else if !pass {
|
||||
return nil, errors.New("当前手机号码已注册")
|
||||
}
|
||||
mUserInstance.Local.Local = c.local
|
||||
mUserInstance.Source = model2.UserInstanceSourceForLocal
|
||||
mUserInstance.Password = utils.GetRandomString(12)
|
||||
mUserInstance.Mobile = params.Mobile
|
||||
|
@ -1,11 +1,17 @@
|
||||
package settled
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/serve/orm"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Company 经纪人入驻信息
|
||||
// Agent 经纪人入驻信息
|
||||
type Agent struct {
|
||||
*session.Enterprise
|
||||
local string
|
||||
@ -15,7 +21,62 @@ type AgentHandle func(session *session.Enterprise, local string) *Agent
|
||||
|
||||
// Launch 经纪人入驻
|
||||
func (c *Agent) Launch(params *BasicParams, other *config.IdentityForAgent) error {
|
||||
return nil
|
||||
if c.Identity&config.TenantUserIdentityForAgent > 0 {
|
||||
return errors.New("操作错误,不可重复申请入驻")
|
||||
}
|
||||
mManageAgent := model.NewManageAgent()
|
||||
// 查询相应的经纪人入驻信息
|
||||
isExist, err := model2.FirstField(mManageAgent.ManageAgent, []string{"id", "status"},
|
||||
model2.NewWhere("id_card", other.IDCard), model2.NewWhere("local", c.local))
|
||||
|
||||
// 用户经纪人入驻信息
|
||||
mUserAgent := model.NewUserAgent()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
// 审核中
|
||||
if mManageAgent.Examine.ExamineStatus == model2.ExamineStatusForOngoing {
|
||||
return errors.New("操作错误,当前该企业信息审核中,不可入驻")
|
||||
}
|
||||
// 审核通过
|
||||
if mManageAgent.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
// 筛选企业条件
|
||||
if err = params.filter(config.TenantUserIdentityForAgent,
|
||||
model2.NewWhere("agent_id", mManageAgent.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
mManageAgent.ID = 0
|
||||
}
|
||||
mManageAgent.Local.Local = c.local
|
||||
mManageAgent.Name = params.Name
|
||||
mManageAgent.Mobile = params.Mobile
|
||||
mManageAgent.IDCard = other.IDCard
|
||||
mManageAgent.SetIndustryAttribute(params.Industrys)
|
||||
mManageAgent.SetKeywordAttribute(params.Keywords)
|
||||
mManageAgent.WorkExperience = other.WorkExperience
|
||||
mManageAgent.WorkPlace = other.WorkPlace
|
||||
mManageAgent.SetCredentialImageAttribute(other.CredentialImages)
|
||||
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
// 删除区域相同身份证经纪人信息
|
||||
if err = model2.DeleteWhere(mManageAgent.ManageAgent, []*model2.ModelWhere{
|
||||
model2.NewWhere("id_card", other.IDCard), model2.NewWhere("local", c.local)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = model2.Create(mManageAgent.ManageAgent, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := model2.UpdatesWhere(mUserAgent.UserAgent, map[string]interface{}{
|
||||
"invalid_status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
mUserAgent.UID = c.UID
|
||||
mUserAgent.AgentID = mManageAgent.ID
|
||||
return model2.Create(mUserAgent.UserAgent, tx)
|
||||
})
|
||||
}
|
||||
|
||||
func NewAgent() AgentHandle {
|
||||
|
@ -36,11 +36,11 @@ func (c *Company) Launch(params *BasicParams, inviterID uint64, other *config.Id
|
||||
return err
|
||||
} else if isExist {
|
||||
// 审核中
|
||||
if mManageCompany.Status == model2.ExamineStatusForOngoing {
|
||||
if mManageCompany.Examine.ExamineStatus == model2.ExamineStatusForOngoing {
|
||||
return errors.New("操作错误,当前该企业信息审核中,不可入驻")
|
||||
}
|
||||
// 审核通过
|
||||
if mManageCompany.Status == model2.ExamineStatusForAgree {
|
||||
if mManageCompany.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
// 筛选企业条件
|
||||
if err = params.filter(config.TenantUserIdentityForCompany,
|
||||
model2.NewWhere("company_id", mManageCompany.ID)); err != nil {
|
||||
@ -72,7 +72,7 @@ func (c *Company) Launch(params *BasicParams, inviterID uint64, other *config.Id
|
||||
return err
|
||||
}
|
||||
if err := model2.UpdatesWhere(mUserCompany.UserCompany, map[string]interface{}{
|
||||
"status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
"invalid_status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -36,13 +36,13 @@ func (c *Expert) Launch(params *BasicParams, other *config.IdentityForExpert) er
|
||||
return err
|
||||
} else if isExist {
|
||||
// 审核中
|
||||
if mManageExpert.Status == model2.ExamineStatusForOngoing {
|
||||
if mManageExpert.Examine.ExamineStatus == model2.ExamineStatusForOngoing {
|
||||
return errors.New("操作错误,当前该专家信息审核中,不可入驻")
|
||||
}
|
||||
// 审核通过
|
||||
if mManageExpert.Status == model2.ExamineStatusForAgree {
|
||||
if mManageExpert.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
// 筛选企业条件
|
||||
if err = params.filter(config.TenantUserIdentityForCompany,
|
||||
if err = params.filter(config.TenantUserIdentityForExpert,
|
||||
model2.NewWhere("expert_id", mManageExpert.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -80,7 +80,7 @@ func (c *Expert) Launch(params *BasicParams, other *config.IdentityForExpert) er
|
||||
return err
|
||||
}
|
||||
if err := model2.UpdatesWhere(mUserExpert.UserExpert, map[string]interface{}{
|
||||
"status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
"invalid_status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -35,13 +35,13 @@ func (c *Laboratory) Launch(params *BasicParams, other *config.IdentityForLabora
|
||||
return err
|
||||
} else if isExist {
|
||||
// 审核中
|
||||
if mManageLaboratory.Status == model2.ExamineStatusForOngoing {
|
||||
if mManageLaboratory.Examine.ExamineStatus == model2.ExamineStatusForOngoing {
|
||||
return errors.New("操作错误,当前该实验室信息审核中,不可入驻")
|
||||
}
|
||||
// 审核通过
|
||||
if mManageLaboratory.Status == model2.ExamineStatusForAgree {
|
||||
if mManageLaboratory.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
// 筛选企业条件
|
||||
if err = params.filter(config.TenantUserIdentityForCompany,
|
||||
if err = params.filter(config.TenantUserIdentityForLaboratory,
|
||||
model2.NewWhere("laboratory_id", mManageLaboratory.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -73,7 +73,7 @@ func (c *Laboratory) Launch(params *BasicParams, other *config.IdentityForLabora
|
||||
return err
|
||||
}
|
||||
if err := model2.UpdatesWhere(mUserLaboratory.UserLaboratory, map[string]interface{}{
|
||||
"status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
"invalid_status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -35,13 +35,13 @@ func (c *Research) Launch(params *BasicParams, other *config.IdentityForResearch
|
||||
return err
|
||||
} else if isExist {
|
||||
// 审核中
|
||||
if mManageResearch.Status == model2.ExamineStatusForOngoing {
|
||||
if mManageResearch.Examine.ExamineStatus == model2.ExamineStatusForOngoing {
|
||||
return errors.New("操作错误,当前该研究机构信息审核中,不可入驻")
|
||||
}
|
||||
// 审核通过
|
||||
if mManageResearch.Status == model2.ExamineStatusForAgree {
|
||||
if mManageResearch.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
// 筛选企业条件
|
||||
if err = params.filter(config.TenantUserIdentityForCompany,
|
||||
if err = params.filter(config.TenantUserIdentityForResearch,
|
||||
model2.NewWhere("research_id", mManageResearch.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -71,7 +71,7 @@ func (c *Research) Launch(params *BasicParams, other *config.IdentityForResearch
|
||||
return err
|
||||
}
|
||||
if err := model2.UpdatesWhere(mUserResearch.UserResearch, map[string]interface{}{
|
||||
"status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
"invalid_status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page
|
||||
mSysPatent := model.NewSysPatent()
|
||||
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("shelf", model2.ShelfStatusForUp),
|
||||
Where: model2.NewWhere("shelf_status", model2.ShelfStatusForUp),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}}
|
||||
|
||||
|
@ -120,7 +120,7 @@ func (c *Instance) Form(params *InstanceParams) error {
|
||||
func (c *Instance) Shelf(id uint64, status int) error {
|
||||
mTechnologyInstance := model.NewTechnologyInstance()
|
||||
mTechnologyInstance.ID = id
|
||||
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "uid", "shelf", "status"})
|
||||
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "uid", "shelf_status", "status"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -130,11 +130,11 @@ func (c *Instance) Shelf(id uint64, status int) error {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForAgree {
|
||||
return errors.New("操作错误,当前状态不允许处理上下架")
|
||||
} else if mTechnologyInstance.ShelfStatus.Shelf == model2.ShelfStatusKind(status) {
|
||||
} else if mTechnologyInstance.Shelf.ShelfStatus == model2.ShelfStatusKind(status) {
|
||||
return errors.New("操作错误,状态异常")
|
||||
}
|
||||
if err = model2.Updates(mTechnologyInstance.TechnologyInstance, map[string]interface{}{
|
||||
"shelf": status, "updated_at": time.Now(),
|
||||
"shelf_status": status, "updated_at": time.Now(),
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ type (
|
||||
// PatentInfo 专利信息
|
||||
PatentInfo struct {
|
||||
*sys.PatentInfo
|
||||
Shelf model2.ShelfStatusKind
|
||||
Status model2.SysParentStatus
|
||||
ShelfStatus model2.ShelfStatusKind
|
||||
Status model2.SysParentStatus
|
||||
}
|
||||
// PatentDetailInfo 专利详细信息
|
||||
PatentDetailInfo struct {
|
||||
@ -176,7 +176,7 @@ func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page
|
||||
ID: v.GetEncodeID(), Title: v.Title, ApplyCode: v.ApplyCode, ApplyName: v.ApplyName,
|
||||
ApplyAt: v.ApplyAt, Inventor: v.Inventor,
|
||||
},
|
||||
Shelf: v.Shelf, Status: v.Status,
|
||||
ShelfStatus: v.ShelfStatus, Status: v.Status,
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
|
@ -149,7 +149,7 @@ func (c *Product) Shelf(id uint64, status int) error {
|
||||
mTechnologyProduct := model.NewTechnologyProduct()
|
||||
mTechnologyProduct.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mTechnologyProduct.TechnologyProduct, []string{"id", "uid", "status"})
|
||||
isExist, err := model2.FirstField(mTechnologyProduct.TechnologyProduct, []string{"id", "uid", "shelf_status", "status"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -157,11 +157,11 @@ func (c *Product) Shelf(id uint64, status int) error {
|
||||
return errors.New("操作错误,产品信息不存在或已被删除")
|
||||
} else if mTechnologyProduct.UID != c.UID {
|
||||
return errors.New("无权限操作")
|
||||
} else if mTechnologyProduct.ShelfStatus.Shelf == model2.ShelfStatusKind(status) {
|
||||
} else if mTechnologyProduct.ShelfStatus == model2.ShelfStatusKind(status) {
|
||||
return errors.New("操作错误,无需变更上下架状态")
|
||||
}
|
||||
return model2.Updates(mTechnologyProduct.TechnologyProduct, map[string]interface{}{
|
||||
"shelf": status, "updated_at": time.Now(),
|
||||
"shelf_status": status, "updated_at": time.Now(),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ func (c *Project) Shelf(id uint64, status int) error {
|
||||
mSysPatent.ID = mUserPatent.PatentID
|
||||
|
||||
return model2.Updates(mSysPatent.SysPatent, map[string]interface{}{
|
||||
"shelf": status, "updated_at": time.Now(),
|
||||
"shelf_status": status, "updated_at": time.Now(),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,7 @@ import (
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/serve/orm"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Settled 入驻
|
||||
@ -80,62 +77,62 @@ func (c *Settled) filter(identity int, where ...*model2.ModelWhere) (bool, error
|
||||
return mSysIdentity.IsExamine == model2.SysIdentityExamineForYes, nil
|
||||
}
|
||||
|
||||
// Company 公司企业
|
||||
func (c *Settled) Company(params *SettledParams, inviterID uint64, other *config.IdentityForCompany) error {
|
||||
mManageCompany := model.NewManageCompany()
|
||||
|
||||
isExist, err := model2.FirstField(mManageCompany.ManageCompany, []string{"id", "status"},
|
||||
model2.NewWhere("code", params.Code), model2.NewWhere("local", c.local),
|
||||
model2.NewWhere("status", model2.ExamineStatusForRefuse))
|
||||
|
||||
isExamine := true
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
if mManageCompany.Status == model2.ExamineStatusForOngoing {
|
||||
return errors.New("操作错误,当前企业信息审核中,不可入驻")
|
||||
}
|
||||
// 筛选企业条件
|
||||
if isExamine, err = c.filter(config.TenantUserIdentityForCompany, model2.NewWhere("company_id", mManageCompany.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
mManageCompany.Local.Local = c.local
|
||||
mManageCompany.InviterID = inviterID
|
||||
mManageCompany.Name = params.Name
|
||||
mManageCompany.Code = params.Code
|
||||
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.WebUrl = other.WebUrl
|
||||
mManageCompany.SetIndustryAttribute(params.Industrys)
|
||||
mManageCompany.SetKeywordAttribute(params.Keywords)
|
||||
mManageCompany.Introduce = params.Introduce
|
||||
|
||||
if isExamine {
|
||||
mManageCompany.Status = model2.ExamineStatusForAgree
|
||||
}
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if mManageCompany.ID <= 0 {
|
||||
if err = model2.Create(mManageCompany.ManageCompany, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// 过滤用户其他公司入驻信息
|
||||
mUserCompany := model.NewUserCompany()
|
||||
|
||||
if err := model2.UpdatesWhere(mUserCompany.UserCompany, map[string]interface{}{
|
||||
"status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
mUserCompany.UID = c.UID
|
||||
mUserCompany.CompanyID = mManageCompany.ID
|
||||
return model2.Create(mUserCompany.UserCompany, tx)
|
||||
})
|
||||
}
|
||||
//// Company 公司企业
|
||||
//func (c *Settled) Company(params *SettledParams, inviterID uint64, other *config.IdentityForCompany) error {
|
||||
// mManageCompany := model.NewManageCompany()
|
||||
//
|
||||
// isExist, err := model2.FirstField(mManageCompany.ManageCompany, []string{"id", "status"},
|
||||
// model2.NewWhere("code", params.Code), model2.NewWhere("local", c.local),
|
||||
// model2.NewWhere("status", model2.ExamineStatusForRefuse))
|
||||
//
|
||||
// isExamine := true
|
||||
//
|
||||
// if err != nil {
|
||||
// return err
|
||||
// } else if isExist {
|
||||
// if mManageCompany.ExamineStatus == model2.ExamineStatusForOngoing {
|
||||
// return errors.New("操作错误,当前企业信息审核中,不可入驻")
|
||||
// }
|
||||
// // 筛选企业条件
|
||||
// if isExamine, err = c.filter(config.TenantUserIdentityForCompany, model2.NewWhere("company_id", mManageCompany.ID)); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
// mManageCompany.Local.Local = c.local
|
||||
// mManageCompany.InviterID = inviterID
|
||||
// mManageCompany.Name = params.Name
|
||||
// mManageCompany.Code = params.Code
|
||||
// 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.Url = other.Url
|
||||
// mManageCompany.SetIndustryAttribute(params.Industrys)
|
||||
// mManageCompany.SetKeywordAttribute(params.Keywords)
|
||||
// mManageCompany.Introduce = params.Introduce
|
||||
//
|
||||
// if isExamine {
|
||||
// mManageCompany.ExamineStatus = model2.ExamineStatusForAgree
|
||||
// }
|
||||
// return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
// if mManageCompany.ID <= 0 {
|
||||
// if err = model2.Create(mManageCompany.ManageCompany, tx); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
// // 过滤用户其他公司入驻信息
|
||||
// mUserCompany := model.NewUserCompany()
|
||||
//
|
||||
// if err := model2.UpdatesWhere(mUserCompany.UserCompany, map[string]interface{}{
|
||||
// "status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
// }, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// mUserCompany.UID = c.UID
|
||||
// mUserCompany.CompanyID = mManageCompany.ID
|
||||
// return model2.Create(mUserCompany.UserCompany, tx)
|
||||
// })
|
||||
//}
|
||||
|
||||
//
|
||||
//// Expert 专家
|
||||
|
Reference in New Issue
Block a user