feat:完善信息,优化入驻接口
This commit is contained in:
@ -107,9 +107,8 @@ func (c *Company) Form(params *BasicParams, other *config.IdentityForCompany) er
|
||||
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 {
|
||||
if params.Code != mManageCompany.Code {
|
||||
if isExist, err = params.isExist(mManageCompany.ManageCompany, model2.NewWhere("code", params.Code)); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前站点下已存在同一公司组织机构代码")
|
||||
@ -143,11 +142,11 @@ func (c *Company) Form(params *BasicParams, other *config.IdentityForCompany) er
|
||||
mManageCompany.ExamineStatus = model2.ExamineStatusForAgree
|
||||
mManageCompany.ExamineRemark = "主动创建,无需审核"
|
||||
|
||||
if isExist, err := params.isExist(mManageCompany.ManageCompany, model2.NewWhere("tenant_id", params.TenantID),
|
||||
if isExist, err := params.isExist(mManageCompany.ManageCompany,
|
||||
model2.NewWhere("code", params.Code)); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前站点下已存在同一公司组织机构代码")
|
||||
return errors.New("操作错误,已存在同一公司组织机构代码")
|
||||
}
|
||||
return model2.Create(mManageCompany.ManageCompany)
|
||||
}
|
||||
|
@ -4,9 +4,14 @@ import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
config2 "SciencesServer/config"
|
||||
cache2 "SciencesServer/serve/cache"
|
||||
"SciencesServer/serve/orm"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
@ -31,6 +36,7 @@ var examineHandle = map[int]func(id, tenantID uint64) (*ExamineManageInfo, error
|
||||
config.TenantUserIdentityForExpert: examineExpert,
|
||||
config.TenantUserIdentityForResearch: examineResearch,
|
||||
config.TenantUserIdentityForLaboratory: examineLaboratory,
|
||||
config.TenantUserIdentityForAgent: examineAgent,
|
||||
}
|
||||
|
||||
func checkManage(IModel model2.IModel, id uint64) error {
|
||||
@ -87,8 +93,8 @@ func examineExpert(id, tenantID uint64) (*ExamineManageInfo, error) {
|
||||
model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ExamineManageInfo{IModel: mManageExpert.ManageExpert, UIDs: uids,
|
||||
Name: mManageExpert.Name, Industrys: mManageExpert.GetIndustryAttribute(),
|
||||
return &ExamineManageInfo{IModel: mManageExpert.ManageExpert, IUserModel: mUserExpert.UserExpert,
|
||||
UIDs: uids, Name: mManageExpert.Name, Industrys: mManageExpert.GetIndustryAttribute(),
|
||||
Keywords: mManageExpert.GetKeywordAttribute(), Researchs: mManageExpert.GetResearchAttribute()}, nil
|
||||
}
|
||||
|
||||
@ -112,7 +118,7 @@ func examineResearch(id, tenantID uint64) (*ExamineManageInfo, error) {
|
||||
model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ExamineManageInfo{IModel: mManageResearch.ManageResearch, UIDs: uids,
|
||||
return &ExamineManageInfo{IModel: mManageResearch.ManageResearch, IUserModel: mUserResearch.UserResearch, UIDs: uids,
|
||||
Name: mManageResearch.Name, Industrys: mManageResearch.GetIndustryAttribute(),
|
||||
Keywords: mManageResearch.GetKeywordAttribute(), Researchs: mManageResearch.GetResearchAttribute()}, nil
|
||||
}
|
||||
@ -137,7 +143,7 @@ func examineLaboratory(id, tenantID uint64) (*ExamineManageInfo, error) {
|
||||
model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ExamineManageInfo{IModel: mManageLaboratory.ManageLaboratory, UIDs: uids,
|
||||
return &ExamineManageInfo{IModel: mManageLaboratory.ManageLaboratory, IUserModel: mUserLaboratory.UserLaboratory, UIDs: uids,
|
||||
Name: mManageLaboratory.Name, Industrys: mManageLaboratory.GetIndustryAttribute(),
|
||||
Keywords: mManageLaboratory.GetKeywordAttribute(), Researchs: mManageLaboratory.GetResearchAttribute()}, nil
|
||||
}
|
||||
@ -162,7 +168,7 @@ func examineAgent(id, tenantID uint64) (*ExamineManageInfo, error) {
|
||||
model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ExamineManageInfo{IModel: mManageAgent.ManageAgent, UIDs: uids,
|
||||
return &ExamineManageInfo{IModel: mManageAgent.ManageAgent, IUserModel: mUserAgent.UserAgent, UIDs: uids,
|
||||
Name: mManageAgent.Name, Industrys: mManageAgent.GetIndustryAttribute(),
|
||||
Keywords: mManageAgent.GetKeywordAttribute()}, nil
|
||||
}
|
||||
@ -186,8 +192,7 @@ func (c *Examine) Launch(id uint64, identity, status int, remark string, params
|
||||
}
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
values := map[string]interface{}{
|
||||
"examine_status": status,
|
||||
"examine_remark": remark, "updated_at": time.Now()}
|
||||
"examine_status": status, "examine_remark": remark, "updated_at": time.Now()}
|
||||
|
||||
if params != nil && len(params) > 0 {
|
||||
if identity == config.TenantUserIdentityForCompany {
|
||||
@ -213,23 +218,35 @@ func (c *Examine) Launch(id uint64, identity, status int, remark string, params
|
||||
return nil
|
||||
}
|
||||
mUserInstance := model.NewUserInstance()
|
||||
|
||||
// 客户端用户信息
|
||||
users := make([]*model2.UserInstance, 0)
|
||||
|
||||
if err = model2.ScanFields(mUserInstance.UserInstance, &users, []string{"id", "uuid", "identity"},
|
||||
if err = model2.ScanFields(mUserInstance.UserInstance, &users, []string{"id", "uuid", "name", "identity"},
|
||||
&model2.ModelWhereOrder{Where: model2.NewWhereIn("uuid", data.UIDs)}); err != nil {
|
||||
return err
|
||||
}
|
||||
userIdentitys := make([]*model2.UserIdentity, 0)
|
||||
|
||||
now := time.Now()
|
||||
|
||||
mUserIdentity := model.NewUserIdentity()
|
||||
|
||||
for _, v := range users {
|
||||
userIdentitys = append(userIdentitys, &model2.UserIdentity{
|
||||
var count int64
|
||||
|
||||
if err = model2.Count(mUserIdentity.UserIdentity, &count, model2.NewWhere("uid", v.UUID)); err != nil {
|
||||
return err
|
||||
}
|
||||
userIdentity := &model2.UserIdentity{
|
||||
Name: v.Name,
|
||||
UID: v.UUID,
|
||||
Identity: identity,
|
||||
ModelAt: model2.ModelAt{CreatedAt: now, UpdatedAt: now},
|
||||
})
|
||||
}
|
||||
if count <= 0 {
|
||||
userIdentity.IsSelected = model2.UserIdentitySelectedForYes
|
||||
}
|
||||
if err = model2.Create(userIdentity, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = model2.UpdatesWhere(mUserInstance.UserInstance, map[string]interface{}{
|
||||
"identity": mUserInstance.Identity | identity, "updated_at": now,
|
||||
}, []*model2.ModelWhere{
|
||||
@ -237,11 +254,22 @@ func (c *Examine) Launch(id uint64, identity, status int, remark string, params
|
||||
}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
// TODO:需要同步redis
|
||||
}
|
||||
if len(userIdentitys) > 0 {
|
||||
if err = model2.Creates(model.NewUserIdentity().UserIdentity, userIdentitys, tx); err != nil {
|
||||
return err
|
||||
|
||||
// 需要同步redis库
|
||||
cache, _ := cache2.Cache.HGet(config2.RedisKeyForAccountEnterprise, fmt.Sprintf("%v", v.UUID))
|
||||
|
||||
if cache != "" {
|
||||
_session := new(session.Enterprise)
|
||||
|
||||
if err := json.Unmarshal([]byte(cache), _session); err != nil {
|
||||
return err
|
||||
}
|
||||
_session.Identity = mUserInstance.Identity | identity
|
||||
|
||||
if userIdentity.IsSelected == model2.UserIdentitySelectedForYes {
|
||||
_session.SelectIdentity = identity
|
||||
}
|
||||
service.Publish(config2.EventForRedisHashProduce, config2.RedisKeyForAccountEnterprise, _session.GetStringUID(), _session)
|
||||
}
|
||||
}
|
||||
// 存放es中
|
||||
|
@ -143,9 +143,8 @@ func (c *Expert) Form(params *BasicParams, other *config.IdentityForExpert) erro
|
||||
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 {
|
||||
if mManageExpert.Mobile != params.Mobile {
|
||||
if isExist, err = params.isExist(mManageExpert.ManageExpert, model2.NewWhere("mobile", params.Mobile)); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前站点下已存在相同手机号码")
|
||||
@ -185,11 +184,11 @@ func (c *Expert) Form(params *BasicParams, other *config.IdentityForExpert) erro
|
||||
mManageExpert.ExamineStatus = model2.ExamineStatusForAgree
|
||||
mManageExpert.ExamineRemark = "主动创建,无需审核"
|
||||
|
||||
if isExist, err := params.isExist(mManageExpert.ManageExpert, model2.NewWhere("tenant_id", params.TenantID),
|
||||
if isExist, err := params.isExist(mManageExpert.ManageExpert,
|
||||
model2.NewWhere("mobile", params.Mobile)); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前站点下已存在相同手机号码")
|
||||
return errors.New("操作错误,已存在相同手机号码")
|
||||
}
|
||||
return model2.Create(mManageExpert.ManageExpert)
|
||||
}
|
||||
|
@ -131,8 +131,8 @@ func (c *Laboratory) Form(params *BasicParams, other *config.IdentityForLaborato
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
} else {
|
||||
if mManageLaboratory.TenantID != params.TenantID {
|
||||
if isExist, err = params.isExist(mManageLaboratory.ManageLaboratory, model2.NewWhere("tenant_id", params.TenantID),
|
||||
if mManageLaboratory.Code != params.Code {
|
||||
if isExist, err = params.isExist(mManageLaboratory.ManageLaboratory,
|
||||
model2.NewWhere("code", params.Code)); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
@ -166,11 +166,11 @@ func (c *Laboratory) Form(params *BasicParams, other *config.IdentityForLaborato
|
||||
mManageLaboratory.ExamineStatus = model2.ExamineStatusForAgree
|
||||
mManageLaboratory.ExamineRemark = "主动创建,无需审核"
|
||||
|
||||
if isExist, err := params.isExist(mManageLaboratory.ManageLaboratory, model2.NewWhere("tenant_id", params.TenantID),
|
||||
if isExist, err := params.isExist(mManageLaboratory.ManageLaboratory,
|
||||
model2.NewWhere("code", params.Code)); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前站点下已存在同一实验室机构代码")
|
||||
return errors.New("操作错误,已存在同一实验室机构代码")
|
||||
}
|
||||
return model2.Create(mManageLaboratory.ManageLaboratory)
|
||||
|
||||
|
@ -101,9 +101,14 @@ func (c *Research) Select(tenantID uint64) ([]*ResearchSelect, error) {
|
||||
|
||||
out := make([]*model2.ManageResearch, 0)
|
||||
|
||||
if err := model2.ScanFields(mManageResearch.ManageResearch, &out, []string{"id", "name"}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("tenant_id", tenantID)}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree)}); err != nil {
|
||||
where := []*model2.ModelWhereOrder{
|
||||
&model2.ModelWhereOrder{Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree)},
|
||||
}
|
||||
if tenantID > 0 {
|
||||
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhere("tenant_id", tenantID)})
|
||||
}
|
||||
|
||||
if err := model2.ScanFields(mManageResearch.ManageResearch, &out, []string{"id", "name"}, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*ResearchSelect, 0)
|
||||
@ -135,8 +140,8 @@ func (c *Research) Form(params *BasicParams, other *config.IdentityForResearch)
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
} else {
|
||||
if mManageResearch.TenantID != params.TenantID {
|
||||
if isExist, err = params.isExist(mManageResearch.ManageResearch, model2.NewWhere("tenant_id", params.TenantID),
|
||||
if mManageResearch.Code != params.Code {
|
||||
if isExist, err = params.isExist(mManageResearch.ManageResearch,
|
||||
model2.NewWhere("code", params.Code)); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
@ -169,11 +174,10 @@ func (c *Research) Form(params *BasicParams, other *config.IdentityForResearch)
|
||||
mManageResearch.ExamineStatus = model2.ExamineStatusForAgree
|
||||
mManageResearch.ExamineRemark = "主动创建,无需审核"
|
||||
|
||||
if isExist, err := params.isExist(mManageResearch.ManageResearch, model2.NewWhere("tenant_id", params.TenantID),
|
||||
model2.NewWhere("code", params.Code)); err != nil {
|
||||
if isExist, err := params.isExist(mManageResearch.ManageResearch, model2.NewWhere("code", params.Code)); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前站点下已存在同一研究机构代码")
|
||||
return errors.New("操作错误,已存在同一研究机构代码")
|
||||
}
|
||||
return model2.Create(mManageResearch.ManageResearch)
|
||||
}
|
||||
|
@ -291,6 +291,11 @@ func (*Manage) ResearchLaboratory(c *gin.Context) {
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Manage) ResearchSelect(c *gin.Context) {
|
||||
data, err := manage.NewResearch()(api.GetSession()(c).(*session.Enterprise)).Select()
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Manage) ResearchVisit(c *gin.Context) {
|
||||
form := &struct {
|
||||
CompanyName string `json:"company_name" form:"company_name"`
|
||||
|
@ -62,7 +62,7 @@ func loginForSmsCaptcha(params *LoginParams, tenantID uint64) (*InstanceLoginPar
|
||||
mUserInstance := model.NewUserInstance()
|
||||
|
||||
if isExist, err = model2.FirstField(mUserInstance.UserInstance, []string{"id", "uuid", "avatar", "name", "mobile",
|
||||
"is_vip", "vip_deadline", "status"},
|
||||
"identity", "is_vip", "vip_deadline", "status"},
|
||||
model2.NewWhere("mobile", params.Captcha.Mobile)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -113,7 +113,7 @@ func loginForPassword(params *LoginParams, tenantID uint64) (*InstanceLoginParam
|
||||
mUserInstance := model.NewUserInstance()
|
||||
|
||||
isExist, err := model2.FirstField(mUserInstance.UserInstance, []string{"id", "uuid", "name", "avatar", "mobile",
|
||||
"is_vip", "vip_deadline", "password", "salt", "status"},
|
||||
"identity", "is_vip", "vip_deadline", "password", "salt", "status"},
|
||||
model2.NewWhere("mobile", params.Password.Account))
|
||||
|
||||
if err != nil {
|
||||
|
@ -28,6 +28,10 @@ type (
|
||||
ID string `json:"id"`
|
||||
*model.ManageExpertCompanyVisitInfo
|
||||
}
|
||||
ResearchSelect struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
)
|
||||
|
||||
// Laboratory 实验室信息
|
||||
@ -71,6 +75,27 @@ func (c *Research) Laboratory(title string, page, pageSize int) (*controller.Ret
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Select 筛选信息
|
||||
func (c *Research) Select() ([]*ResearchSelect, error) {
|
||||
mManageResearch := model.NewManageResearch()
|
||||
|
||||
out := make([]*model2.ManageResearch, 0)
|
||||
|
||||
if err := model2.ScanFields(mManageResearch.ManageResearch, &out, []string{"id", "name"}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree)}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*ResearchSelect, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &ResearchSelect{
|
||||
ID: v.GetEncodeID(),
|
||||
Name: v.Name,
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// Visit 访问记录
|
||||
func (c *Research) Visit(page, pageSize int) (*controller.ReturnPages, error) {
|
||||
// 获取当前科研机构下所有的专家人员
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"SciencesServer/serve/orm"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Agent 经纪人入驻信息
|
||||
@ -35,18 +34,50 @@ func (c *Agent) Launch(params *BasicParams, other *config.IdentityForAgent) erro
|
||||
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 {
|
||||
if mManageAgent.Examine.ExamineStatus == model2.ExamineStatusForOngoing ||
|
||||
mManageAgent.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
// 筛选判断是否满足入驻条件
|
||||
if err = params.filter(config.TenantUserIdentityForAgent, model2.NewWhere("agent_id", mManageAgent.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
// 判断当前用户是否入驻
|
||||
var count int64
|
||||
|
||||
if err = model2.Count(mUserAgent.UserAgent, &count, model2.NewWhere("agent_id", mManageAgent.ID),
|
||||
model2.NewWhere("uid", c.UID), model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil {
|
||||
return err
|
||||
}
|
||||
if count > 0 {
|
||||
return errors.New("操作错误,已申请入驻,不可重复申请")
|
||||
}
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
mUserAgent.UID = c.UID
|
||||
mUserAgent.AgentID = mManageAgent.ID
|
||||
|
||||
if err = model2.Create(mUserAgent.UserAgent, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
// 直接同步身份信息
|
||||
if mManageAgent.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
if err = params.fillIdentity(tx, c.Enterprise, config.TenantUserIdentityForAgent); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
// 审核中
|
||||
//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.TenantID = c.tenantID
|
||||
@ -63,21 +94,12 @@ func (c *Agent) Launch(params *BasicParams, other *config.IdentityForAgent) erro
|
||||
mManageAgent.WorkExperience = other.WorkExperience
|
||||
mManageAgent.WorkPlace = other.WorkPlace
|
||||
mManageAgent.SetCredentialImageAttribute(other.CredentialImages)
|
||||
mManageAgent.ExamineStatus = model2.ExamineStatusForOngoing
|
||||
|
||||
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("tenant_id", c.tenantID)}, 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)
|
||||
|
@ -47,7 +47,7 @@ func (c *BasicParams) filter(identity int, where ...*model2.ModelWhere) error {
|
||||
}
|
||||
var count int64
|
||||
|
||||
where = append(where, model2.NewWhere("status", model2.InvalidStatusForNot))
|
||||
where = append(where, model2.NewWhere("invalid_status", model2.InvalidStatusForNot))
|
||||
|
||||
if err = model2.Count(iModel, &count, where...); err != nil {
|
||||
return err
|
||||
|
@ -118,6 +118,7 @@ func (c *Company) Launch(params *BasicParams, inviterID uint64, other *config.Id
|
||||
mManageCompany.SetKeywordAttribute(params.Keywords)
|
||||
mManageCompany.SetDirectionAttribute(other.Directions)
|
||||
mManageCompany.Introduce = params.Introduce
|
||||
mManageCompany.ExamineStatus = model2.ExamineStatusForOngoing
|
||||
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.Create(mManageCompany.ManageCompany, tx); err != nil {
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Expert 专家入驻信息
|
||||
@ -28,26 +27,47 @@ func (c *Expert) Launch(params *BasicParams, other *config.IdentityForExpert) er
|
||||
mManageExpert := model.NewManageExpert()
|
||||
// 查询相应专家入驻信息
|
||||
isExist, err := model2.FirstField(mManageExpert.ManageExpert, []string{"id", "examine_status"},
|
||||
model2.NewWhere("mobile", params.Mobile), model2.NewWhere("tenant_id", c.tenantID))
|
||||
|
||||
model2.NewWhere("mobile", params.Mobile),
|
||||
//, model2.NewWhere("tenant_id", c.tenantID)
|
||||
)
|
||||
mUserExpert := model.NewUserExpert()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
// 审核中
|
||||
if mManageExpert.Examine.ExamineStatus == model2.ExamineStatusForOngoing {
|
||||
return errors.New("操作错误,当前该专家信息审核中,不可入驻")
|
||||
}
|
||||
// 审核通过
|
||||
if mManageExpert.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
// 筛选企业条件
|
||||
if err = params.filter(config.TenantUserIdentityForExpert,
|
||||
model2.NewWhere("expert_id", mManageExpert.ID)); err != nil {
|
||||
if mManageExpert.Examine.ExamineStatus == model2.ExamineStatusForOngoing ||
|
||||
mManageExpert.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
// 筛选判断是否满足入驻条件
|
||||
if err = params.filter(config.TenantUserIdentityForExpert, model2.NewWhere("expert_id", mManageExpert.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
// 判断当前用户是否入驻
|
||||
var count int64
|
||||
|
||||
if err = model2.Count(mUserExpert.UserExpert, &count, model2.NewWhere("expert_id", mManageExpert.ID),
|
||||
model2.NewWhere("uid", c.UID), model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil {
|
||||
return err
|
||||
}
|
||||
if count > 0 {
|
||||
return errors.New("操作错误,已申请入驻,不可重复申请")
|
||||
}
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
mUserExpert.UID = c.UID
|
||||
mUserExpert.ExpertID = mManageExpert.ID
|
||||
|
||||
if err = model2.Create(mUserExpert.UserExpert, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
// 直接同步身份信息
|
||||
if mManageExpert.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
if err = params.fillIdentity(tx, c.Enterprise, config.TenantUserIdentityForExpert); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
mUserExpert.ID = 0
|
||||
mManageExpert.ID = 0
|
||||
}
|
||||
mManageExpert.TenantID = c.tenantID
|
||||
mManageExpert.ResearchID = other.ConvertResearch()
|
||||
@ -58,7 +78,6 @@ func (c *Expert) Launch(params *BasicParams, other *config.IdentityForExpert) er
|
||||
mManageExpert.Area = model2.Area{
|
||||
Province: params.Area.Province, City: params.Area.City, District: params.Area.District, Address: params.Area.Address,
|
||||
}
|
||||
//mManageExpert.Position = params.Mobile
|
||||
mManageExpert.Education = other.Education
|
||||
mManageExpert.School = other.School
|
||||
mManageExpert.Major = other.Major
|
||||
@ -70,21 +89,12 @@ func (c *Expert) Launch(params *BasicParams, other *config.IdentityForExpert) er
|
||||
mManageExpert.SetKeywordAttribute(params.Keywords)
|
||||
mManageExpert.SetResearchAttribute(other.Researchs)
|
||||
mManageExpert.Introduce = params.Introduce
|
||||
mManageExpert.ExamineStatus = model2.ExamineStatusForOngoing
|
||||
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
// 删除区域相同编码公司信息
|
||||
if err = model2.DeleteWhere(mManageExpert.ManageExpert, []*model2.ModelWhere{
|
||||
model2.NewWhere("mobile", params.Mobile), model2.NewWhere("tenant_id", c.tenantID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = model2.Create(mManageExpert.ManageExpert, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := model2.UpdatesWhere(mUserExpert.UserExpert, map[string]interface{}{
|
||||
"invalid_status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
mUserExpert.UID = c.UID
|
||||
mUserExpert.ExpertID = mManageExpert.ID
|
||||
return model2.Create(mUserExpert.UserExpert, tx)
|
||||
|
@ -88,10 +88,16 @@ func (c *Instance) Index() (*InstanceInfo, error) {
|
||||
if !isExist {
|
||||
continue
|
||||
}
|
||||
out.ExamineIdentity[k] = &InstanceExamineInfo{
|
||||
Status: examine.ExamineStatus,
|
||||
data := &InstanceExamineInfo{
|
||||
Remark: examine.ExamineRemark,
|
||||
}
|
||||
if examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
continue
|
||||
}
|
||||
if examine.ExamineStatus == model2.ExamineStatusForRefuse {
|
||||
data.Status = 2
|
||||
}
|
||||
out.ExamineIdentity[k] = data
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"SciencesServer/serve/orm"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Laboratory 实验室入驻信息
|
||||
@ -27,25 +26,57 @@ func (c *Laboratory) Launch(params *BasicParams, other *config.IdentityForLabora
|
||||
mManageLaboratory := model.NewManageLaboratory()
|
||||
// 查询相应专家入驻信息
|
||||
isExist, err := model2.FirstField(mManageLaboratory.ManageLaboratory, []string{"id", "examine_status"},
|
||||
model2.NewWhere("code", params.Code), model2.NewWhere("tenant_id", c.tenantID))
|
||||
model2.NewWhere("code", params.Code))
|
||||
|
||||
mUserLaboratory := model.NewUserLaboratory()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
// 审核中
|
||||
if mManageLaboratory.Examine.ExamineStatus == model2.ExamineStatusForOngoing {
|
||||
return errors.New("操作错误,当前该实验室信息审核中,不可入驻")
|
||||
}
|
||||
// 审核通过
|
||||
if mManageLaboratory.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
// 筛选企业条件
|
||||
if err = params.filter(config.TenantUserIdentityForLaboratory,
|
||||
model2.NewWhere("laboratory_id", mManageLaboratory.ID)); err != nil {
|
||||
if mManageLaboratory.Examine.ExamineStatus == model2.ExamineStatusForOngoing ||
|
||||
mManageLaboratory.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
// 筛选判断是否满足入驻条件
|
||||
if err = params.filter(config.TenantUserIdentityForLaboratory, model2.NewWhere("laboratory_id", mManageLaboratory.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
// 判断当前用户是否入驻
|
||||
var count int64
|
||||
|
||||
if err = model2.Count(mUserLaboratory.UserLaboratory, &count, model2.NewWhere("laboratory_id", mManageLaboratory.ID),
|
||||
model2.NewWhere("uid", c.UID), model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil {
|
||||
return err
|
||||
}
|
||||
if count > 0 {
|
||||
return errors.New("操作错误,已申请入驻,不可重复申请")
|
||||
}
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
mUserLaboratory.UID = c.UID
|
||||
mUserLaboratory.LaboratoryID = mManageLaboratory.ID
|
||||
|
||||
if err = model2.Create(mUserLaboratory.UserLaboratory, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
// 直接同步身份信息
|
||||
if mManageLaboratory.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
if err = params.fillIdentity(tx, c.Enterprise, config.TenantUserIdentityForLaboratory); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
//// 审核中
|
||||
//if mManageLaboratory.Examine.ExamineStatus == model2.ExamineStatusForOngoing {
|
||||
// return errors.New("操作错误,当前该实验室信息审核中,不可入驻")
|
||||
//}
|
||||
//// 审核通过
|
||||
//if mManageLaboratory.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
// // 筛选企业条件
|
||||
// if err = params.filter(config.TenantUserIdentityForLaboratory,
|
||||
// model2.NewWhere("laboratory_id", mManageLaboratory.ID)); err != nil {
|
||||
// return err
|
||||
// }
|
||||
//}
|
||||
mManageLaboratory.ID = 0
|
||||
}
|
||||
mManageLaboratory.TenantID = c.tenantID
|
||||
@ -62,21 +93,12 @@ func (c *Laboratory) Launch(params *BasicParams, other *config.IdentityForLabora
|
||||
mManageLaboratory.SetKeywordAttribute(params.Keywords)
|
||||
mManageLaboratory.SetResearchAttribute(other.Researchs)
|
||||
mManageLaboratory.Introduce = params.Introduce
|
||||
mManageLaboratory.ExamineStatus = model2.ExamineStatusForOngoing
|
||||
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
// 删除区域相同编码公司信息
|
||||
if err = model2.DeleteWhere(mManageLaboratory.ManageLaboratory, []*model2.ModelWhere{
|
||||
model2.NewWhere("code", params.Code), model2.NewWhere("tenant_id", c.tenantID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = model2.Create(mManageLaboratory.ManageLaboratory, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := model2.UpdatesWhere(mUserLaboratory.UserLaboratory, map[string]interface{}{
|
||||
"invalid_status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
mUserLaboratory.UID = c.UID
|
||||
mUserLaboratory.LaboratoryID = mManageLaboratory.ID
|
||||
return model2.Create(mUserLaboratory.UserLaboratory, tx)
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"SciencesServer/serve/orm"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Research 研究机构入驻信息
|
||||
@ -27,24 +26,44 @@ func (c *Research) Launch(params *BasicParams, other *config.IdentityForResearch
|
||||
mManageResearch := model.NewManageResearch()
|
||||
// 查询相应专家入驻信息
|
||||
isExist, err := model2.FirstField(mManageResearch.ManageResearch, []string{"id", "examine_status"},
|
||||
model2.NewWhere("code", params.Code), model2.NewWhere("tenant_id", c.tenantID))
|
||||
model2.NewWhere("code", params.Code))
|
||||
|
||||
mUserResearch := model.NewUserResearch()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
// 审核中
|
||||
if mManageResearch.Examine.ExamineStatus == model2.ExamineStatusForOngoing {
|
||||
return errors.New("操作错误,当前该研究机构信息审核中,不可入驻")
|
||||
}
|
||||
// 审核通过
|
||||
if mManageResearch.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
// 筛选企业条件
|
||||
if err = params.filter(config.TenantUserIdentityForResearch,
|
||||
model2.NewWhere("research_id", mManageResearch.ID)); err != nil {
|
||||
if mManageResearch.Examine.ExamineStatus == model2.ExamineStatusForOngoing ||
|
||||
mManageResearch.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
// 筛选判断是否满足入驻条件
|
||||
if err = params.filter(config.TenantUserIdentityForResearch, model2.NewWhere("research_id", mManageResearch.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
// 判断当前用户是否入驻
|
||||
var count int64
|
||||
|
||||
if err = model2.Count(mUserResearch.UserResearch, &count, model2.NewWhere("research_id", mManageResearch.ID),
|
||||
model2.NewWhere("uid", c.UID), model2.NewWhere("invalid_status", model2.InvalidStatusForNot)); err != nil {
|
||||
return err
|
||||
}
|
||||
if count > 0 {
|
||||
return errors.New("操作错误,已申请入驻,不可重复申请")
|
||||
}
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
mUserResearch.UID = c.UID
|
||||
mUserResearch.ResearchID = mManageResearch.ID
|
||||
|
||||
if err = model2.Create(mUserResearch.UserResearch, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
// 直接同步身份信息
|
||||
if mManageResearch.Examine.ExamineStatus == model2.ExamineStatusForAgree {
|
||||
if err = params.fillIdentity(tx, c.Enterprise, config.TenantUserIdentityForResearch); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
mManageResearch.ID = 0
|
||||
}
|
||||
@ -61,21 +80,13 @@ func (c *Research) Launch(params *BasicParams, other *config.IdentityForResearch
|
||||
mManageResearch.SetResearchAttribute(other.Researchs)
|
||||
mManageResearch.License = other.FilterLicense()
|
||||
mManageResearch.Introduce = params.Introduce
|
||||
mManageResearch.ExamineStatus = model2.ExamineStatusForOngoing
|
||||
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
// 删除区域相同编码公司信息
|
||||
if err = model2.DeleteWhere(mManageResearch.ManageResearch, []*model2.ModelWhere{
|
||||
model2.NewWhere("code", params.Code), model2.NewWhere("tenant_id", c.tenantID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = model2.Create(mManageResearch.ManageResearch, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := model2.UpdatesWhere(mUserResearch.UserResearch, map[string]interface{}{
|
||||
"invalid_status": model2.InvalidStatusForYes, "updated_at": time.Now(),
|
||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.UID)}, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
mUserResearch.UID = c.UID
|
||||
mUserResearch.ResearchID = mManageResearch.ID
|
||||
return model2.Create(mUserResearch.UserResearch, tx)
|
||||
|
@ -24,7 +24,8 @@ func (m *UserAgent) Settled(uid uint64) (*UserSettledInfo, error) {
|
||||
Select("u.id", "c.examine_status", "c.examine_remark").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u.agent_id = c.id", model.NewManageAgent().TableName())).
|
||||
Where("u.uid = ?", uid).
|
||||
Where("u.is_deleted = ? AND u.invalid_status = ?", model.DeleteStatusForNot, model.InvalidStatusForNot).
|
||||
Where("u.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Order("u.id " + model.OrderModeToDesc).Limit(1).
|
||||
Scan(out).Error
|
||||
return out, err
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ type (
|
||||
}
|
||||
UserCompanyInfo struct {
|
||||
*model.ManageCompany
|
||||
UserCompanyID uint64 `json-"`
|
||||
UserCompanyID uint64 `json:"user_company_id"`
|
||||
}
|
||||
)
|
||||
|
||||
@ -29,7 +29,8 @@ func (m *UserCompany) Settled(uid uint64) (*UserSettledInfo, error) {
|
||||
Select("u.id", "c.examine_status", "c.examine_remark").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u.company_id = c.id", model.NewManageCompany().TableName())).
|
||||
Where("u.uid = ?", uid).
|
||||
Where("u.is_deleted = ? AND u.invalid_status = ?", model.DeleteStatusForNot, model.InvalidStatusForNot).
|
||||
Where("u.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Order("u.id " + model.OrderModeToDesc).Limit(1).
|
||||
Scan(out).Error
|
||||
return out, err
|
||||
}
|
||||
|
@ -25,7 +25,8 @@ func (m *UserExpert) Settled(uid uint64) (*UserSettledInfo, error) {
|
||||
Select("u.id", "c.examine_status", "c.examine_remark").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u.expert_id = c.id", model.NewManageExpert().TableName())).
|
||||
Where("u.uid = ?", uid).
|
||||
Where("u.is_deleted = ? AND u.invalid_status = ?", model.DeleteStatusForNot, model.InvalidStatusForNot).
|
||||
Where("u.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Order("u.id " + model.OrderModeToDesc).Limit(1).
|
||||
Scan(out).Error
|
||||
return out, err
|
||||
}
|
||||
|
@ -24,7 +24,8 @@ func (m *UserLaboratory) Settled(uid uint64) (*UserSettledInfo, error) {
|
||||
Select("u.id", "c.examine_status", "c.examine_remark").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u.laboratory_id = c.id", model.NewManageLaboratory().TableName())).
|
||||
Where("u.uid = ?", uid).
|
||||
Where("u.is_deleted = ? AND u.invalid_status = ?", model.DeleteStatusForNot, model.InvalidStatusForNot).
|
||||
Where("u.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Order("u.id " + model.OrderModeToDesc).Limit(1).
|
||||
Scan(out).Error
|
||||
return out, err
|
||||
}
|
||||
|
@ -24,7 +24,8 @@ func (m *UserResearch) Settled(uid uint64) (*UserSettledInfo, error) {
|
||||
Select("u.id", "c.examine_status", "c.examine_remark").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u.research_id = c.id", model.NewManageResearch().TableName())).
|
||||
Where("u.uid = ?", uid).
|
||||
Where("u.is_deleted = ? AND u.invalid_status = ?", model.DeleteStatusForNot, model.InvalidStatusForNot).
|
||||
Where("u.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Order("u.id " + model.OrderModeToDesc).Limit(1).
|
||||
Scan(out).Error
|
||||
return out, err
|
||||
}
|
||||
|
@ -554,6 +554,7 @@ func registerEnterpriseAPI(app *gin.Engine) {
|
||||
manageV1.POST("/company/detail", _api.CompanyDetail)
|
||||
manageV1.POST("/company/product", _api.CompanyProduct)
|
||||
manageV1.POST("/expert", _api.Expert)
|
||||
manageV1.GET("/research/select", _api.ResearchSelect)
|
||||
manageV1.POST("/research/laboratory", _api.ResearchLaboratory)
|
||||
manageV1.POST("/research/visit", _api.ResearchVisit)
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func (this *Router) Init() *gin.Engine {
|
||||
app.Use(ginprom.PromMiddleware(nil))
|
||||
app.Use(LoggerHandle("log/gin.log", 3))
|
||||
app.Use(TimeoutHandle(time.Second * 30))
|
||||
app.Use(RecoveryHandler())
|
||||
//app.Use(RecoveryHandler())
|
||||
|
||||
app.GET("/metrics", ginprom.PromHandler(promhttp.Handler()))
|
||||
|
||||
|
Reference in New Issue
Block a user