feat:完善产品详情
This commit is contained in:
@ -17,6 +17,151 @@ type Identity struct{ *session.Enterprise }
|
||||
|
||||
type IdentityHandle func(session *session.Enterprise) *Identity
|
||||
|
||||
type (
|
||||
// IdentityForCompany 公司信息
|
||||
IdentityForCompany struct {
|
||||
ID string `json:"id"`
|
||||
*model2.ManageCompany
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
Directions []string `json:"directions"`
|
||||
}
|
||||
// IdentityForExpert 专家信息
|
||||
IdentityForExpert struct {
|
||||
ID string `json:"id"`
|
||||
*model2.ManageExpert
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
Researchs []string `json:"researchs"`
|
||||
}
|
||||
// IdentityForResearch 科研机构信息
|
||||
IdentityForResearch struct {
|
||||
ID string `json:"id"`
|
||||
*model2.ManageResearch
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
Researchs []string `json:"researchs"`
|
||||
}
|
||||
// IdentityForLaboratory 实验室信息
|
||||
IdentityForLaboratory struct {
|
||||
ID string `json:"id"`
|
||||
*model2.ManageLaboratory
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
Researchs []string `json:"researchs"`
|
||||
}
|
||||
// IdentityForAgent 经纪人信息
|
||||
IdentityForAgent struct {
|
||||
ID string `json:"id"`
|
||||
*model2.ManageAgent
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
IDImage *model2.ManageAgentIDImage `json:"id_images"`
|
||||
CredentialImages []string `json:"credential_images"`
|
||||
}
|
||||
)
|
||||
|
||||
// company 公司信息
|
||||
func (c *Identity) company() (*IdentityForCompany, error) {
|
||||
mUserCompany := model.NewUserCompany()
|
||||
out, err := mUserCompany.Company(c.UID)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if out.UserCompanyID <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return &IdentityForCompany{
|
||||
ID: (&model2.Model{ID: out.UserCompanyID}).GetEncodeID(),
|
||||
ManageCompany: out.ManageCompany,
|
||||
Industrys: out.GetIndustryAttribute(),
|
||||
Keywords: out.GetKeywordAttribute(),
|
||||
Directions: out.GetDirectionAttribute(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Identity) companyEdit() {
|
||||
|
||||
}
|
||||
|
||||
// expert 专家信息
|
||||
func (c *Identity) expert() (*IdentityForExpert, error) {
|
||||
mUserExpert := model.NewUserExpert()
|
||||
out, err := mUserExpert.Expert(c.UID)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if out.UserExpertID <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return &IdentityForExpert{
|
||||
ID: (&model2.Model{ID: out.UserExpertID}).GetEncodeID(),
|
||||
ManageExpert: out.ManageExpert,
|
||||
Industrys: out.GetIndustryAttribute(),
|
||||
Keywords: out.GetKeywordAttribute(),
|
||||
Researchs: out.GetResearchAttribute(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// research 科研机构信息
|
||||
func (c *Identity) research() (*IdentityForResearch, error) {
|
||||
mUserResearch := model.NewUserResearch()
|
||||
out, err := mUserResearch.Research(c.UID)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if out.UserResearchID <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return &IdentityForResearch{
|
||||
ID: (&model2.Model{ID: out.UserResearchID}).GetEncodeID(),
|
||||
ManageResearch: out.ManageResearch,
|
||||
Industrys: out.GetIndustryAttribute(),
|
||||
Keywords: out.GetKeywordAttribute(),
|
||||
Researchs: out.GetResearchAttribute(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
// Laboratory 实验室信息
|
||||
func (c *Identity) laboratory() (*IdentityForLaboratory, error) {
|
||||
mUserLaboratory := model.NewUserLaboratory()
|
||||
out, err := mUserLaboratory.Laboratory(c.UID)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if out.UserLaboratoryID <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return &IdentityForLaboratory{
|
||||
ID: (&model2.Model{ID: out.UserLaboratoryID}).GetEncodeID(),
|
||||
ManageLaboratory: out.ManageLaboratory,
|
||||
Industrys: out.GetIndustryAttribute(),
|
||||
Keywords: out.GetKeywordAttribute(),
|
||||
Researchs: out.GetResearchAttribute(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// agent 经纪人信息
|
||||
func (c *Identity) agent() (*IdentityForAgent, error) {
|
||||
mUserAgent := model.NewUserAgent()
|
||||
out, err := mUserAgent.Agent(c.UID)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if out.UserAgentID <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return &IdentityForAgent{
|
||||
ID: (&model2.Model{ID: out.UserAgentID}).GetEncodeID(),
|
||||
ManageAgent: out.ManageAgent,
|
||||
Industrys: out.GetIndustryAttribute(),
|
||||
Keywords: out.GetKeywordAttribute(),
|
||||
IDImage: out.GetIDImageAttribute(),
|
||||
CredentialImages: out.GetCredentialImageAttribute(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Basic 详细信息
|
||||
func (c *Identity) Basic() (*InstanceDetailInfo, error) {
|
||||
resp := &InstanceDetailInfo{InstanceInfo: InstanceInfo{Name: c.Name, Identity: c.Identity, SelectIdentity: c.SelectIdentity}}
|
||||
@ -40,7 +185,18 @@ func (c *Identity) Basic() (*InstanceDetailInfo, error) {
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Identity) Detail() (*InstanceDetailInfo, error) {
|
||||
func (c *Identity) Detail() (interface{}, error) {
|
||||
if c.Identity == config.TenantUserIdentityForCompany { // 公司企业身份
|
||||
return c.company()
|
||||
} else if c.Identity == config.TenantUserIdentityForExpert { // 专家身份
|
||||
return c.expert()
|
||||
} else if c.Identity == config.TenantUserIdentityForResearch { // 科研机构身份
|
||||
return c.research()
|
||||
} else if c.Identity == config.TenantUserIdentityForLaboratory { // 实验室身份
|
||||
return c.laboratory()
|
||||
} else if c.Identity == config.TenantUserIdentityForAgent { // 经纪人身份
|
||||
return c.agent()
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user