feat:完善入驻信息管理
This commit is contained in:
@ -1,7 +1,13 @@
|
||||
package settled
|
||||
|
||||
import "SciencesServer/app/session"
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
)
|
||||
|
||||
// Instance 首页信息
|
||||
type Instance struct {
|
||||
*session.Enterprise
|
||||
local string
|
||||
@ -9,8 +15,77 @@ type Instance struct {
|
||||
|
||||
type InstanceHandle func(session *session.Enterprise, local string) *Instance
|
||||
|
||||
func (c *Instance) Index() {
|
||||
type InstanceInfo struct {
|
||||
Identity int `json:"identity"` // 所有身份
|
||||
ExamineIdentity map[int]model2.ExamineStatusKind `json:"examine_identity"` // 审核中信息
|
||||
SelectIdentity int `json:"select_identity"` // 当前选择的身份
|
||||
}
|
||||
|
||||
func (c *Instance) company() (bool, model2.ExamineStatusKind, error) {
|
||||
mUserCompany := model.NewUserCompany()
|
||||
out, err := mUserCompany.Company(c.UID)
|
||||
return out.ID > 0, out.ExamineStatus, err
|
||||
}
|
||||
|
||||
func (c *Instance) expert() (bool, model2.ExamineStatusKind, error) {
|
||||
mUserExpert := model.NewUserExpert()
|
||||
out, err := mUserExpert.Expert(c.UID)
|
||||
return out.ID > 0, out.ExamineStatus, err
|
||||
}
|
||||
|
||||
func (c *Instance) research() (bool, model2.ExamineStatusKind, error) {
|
||||
mUserResearch := model.NewUserResearch()
|
||||
out, err := mUserResearch.Research(c.UID)
|
||||
return out.ID > 0, out.ExamineStatus, err
|
||||
}
|
||||
|
||||
func (c *Instance) laboratory() (bool, model2.ExamineStatusKind, error) {
|
||||
mUserLaboratory := model.NewUserLaboratory()
|
||||
out, err := mUserLaboratory.Laboratory(c.UID)
|
||||
return out.ID > 0, out.ExamineStatus, err
|
||||
}
|
||||
|
||||
func (c *Instance) agent() (bool, model2.ExamineStatusKind, error) {
|
||||
mUserAgent := model.NewUserAgent()
|
||||
out, err := mUserAgent.Agent(c.UID)
|
||||
return out.ID > 0, out.ExamineStatus, err
|
||||
}
|
||||
|
||||
func (c *Instance) Index() (*InstanceInfo, error) {
|
||||
out := &InstanceInfo{
|
||||
Identity: c.Identity,
|
||||
ExamineIdentity: make(map[int]model2.ExamineStatusKind, 0),
|
||||
SelectIdentity: c.SelectIdentity,
|
||||
}
|
||||
isExist := false
|
||||
var kind model2.ExamineStatusKind
|
||||
var err error
|
||||
|
||||
// 查询其他信息
|
||||
for k := range config.TenantUserIdentityData {
|
||||
if k&c.SelectIdentity > 0 {
|
||||
continue
|
||||
}
|
||||
if k == config.TenantUserIdentityForCompany {
|
||||
isExist, kind, err = c.company()
|
||||
} else if k == config.TenantUserIdentityForExpert {
|
||||
isExist, kind, err = c.expert()
|
||||
} else if k == config.TenantUserIdentityForResearch {
|
||||
isExist, kind, err = c.research()
|
||||
} else if k == config.TenantUserIdentityForLaboratory {
|
||||
isExist, kind, err = c.laboratory()
|
||||
} else if k == config.TenantUserIdentityForAgent {
|
||||
isExist, kind, err = c.agent()
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !isExist {
|
||||
continue
|
||||
}
|
||||
out.ExamineIdentity[k] = kind
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
|
Reference in New Issue
Block a user