2021-12-24 12:00:18 +08:00
|
|
|
package manage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"SciencesServer/app/api/website/model"
|
2022-01-25 16:37:12 +08:00
|
|
|
"SciencesServer/app/basic/config"
|
2021-12-24 12:00:18 +08:00
|
|
|
"SciencesServer/app/basic/controller"
|
|
|
|
model2 "SciencesServer/app/common/model"
|
|
|
|
"SciencesServer/app/session"
|
2022-01-25 16:37:12 +08:00
|
|
|
config2 "SciencesServer/config"
|
|
|
|
"SciencesServer/utils"
|
|
|
|
"fmt"
|
2021-12-24 12:00:18 +08:00
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Expert struct {
|
|
|
|
*session.Enterprise
|
|
|
|
}
|
|
|
|
|
|
|
|
type ExpertHandle func(session *session.Enterprise) *Expert
|
|
|
|
|
|
|
|
type (
|
|
|
|
// ExpertBasicInfo 基本信息
|
|
|
|
ExpertBasicInfo struct {
|
2022-01-26 10:34:29 +08:00
|
|
|
ID string `json:"id"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
School string `json:"school"`
|
|
|
|
Image string `json:"image"`
|
|
|
|
Major string `json:"major"`
|
|
|
|
Industrys []string `json:"industrys"`
|
|
|
|
Keywords []string `json:"keywords"`
|
|
|
|
PatentTitle []string `json:"patent_title"`
|
2021-12-24 12:00:18 +08:00
|
|
|
}
|
|
|
|
// ExpertInstanceInfo 专家信息
|
|
|
|
ExpertInstanceInfo struct {
|
|
|
|
ExpertBasicInfo
|
2022-01-26 10:34:29 +08:00
|
|
|
ResearchName string `json:"research_name"`
|
|
|
|
Researchs []string `json:"researchs"`
|
|
|
|
Introduce string `json:"introduce"`
|
|
|
|
Videos []string `json:"videos"`
|
2021-12-24 12:00:18 +08:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2021-12-24 15:28:46 +08:00
|
|
|
func (c *Expert) user(id uint64) ([]uint64, error) {
|
|
|
|
mUserExpert := model.NewUserExpert()
|
|
|
|
|
|
|
|
uids := make([]uint64, 0)
|
|
|
|
|
|
|
|
err := model2.Pluck(mUserExpert.UserExpert, "uid", &uids, model2.NewWhere("expert_id", id))
|
|
|
|
|
|
|
|
return uids, err
|
|
|
|
}
|
|
|
|
|
2021-12-24 12:00:18 +08:00
|
|
|
// Instance 专家信息
|
|
|
|
func (c *Expert) Instance(id uint64) (*ExpertInstanceInfo, error) {
|
|
|
|
mManageExpert := model.NewManageExpert()
|
|
|
|
out, err := mManageExpert.Detail(3, id)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2022-02-06 18:01:32 +08:00
|
|
|
mTechnologyPatent := model.NewTechnologyPatent()
|
2022-01-25 16:37:12 +08:00
|
|
|
|
|
|
|
patentTitles := make([]string, 0)
|
|
|
|
|
|
|
|
if out.PatentTitle != "" {
|
|
|
|
for _, val := range strings.Split(out.PatentTitle, "&&") {
|
|
|
|
objs := strings.Split(val, "$$")
|
2022-02-08 08:56:28 +08:00
|
|
|
mTechnologyPatent.Kind = model2.TechnologyPatentKind(utils.StringToInt(objs[0]))
|
2022-02-06 18:01:32 +08:00
|
|
|
patentTitles = append(patentTitles, fmt.Sprintf("【%s】%s", mTechnologyPatent.KindTitle(), objs[1]))
|
2022-01-25 16:37:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_industrys := make([]string, 0)
|
|
|
|
|
|
|
|
for _, v := range out.GetIndustryAttribute() {
|
|
|
|
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "/").Value)
|
|
|
|
}
|
2022-01-26 16:14:16 +08:00
|
|
|
// 查询成果信息
|
|
|
|
|
2021-12-24 12:00:18 +08:00
|
|
|
return &ExpertInstanceInfo{
|
|
|
|
ExpertBasicInfo: ExpertBasicInfo{
|
2022-01-26 10:34:29 +08:00
|
|
|
ID: out.GetEncodeID(),
|
|
|
|
Name: out.Name,
|
|
|
|
Image: out.Image.Analysis(config2.SystemConfig[config2.SysImageDomain]),
|
|
|
|
School: out.School,
|
|
|
|
Major: out.Major,
|
|
|
|
Industrys: _industrys,
|
|
|
|
Keywords: out.GetKeywordAttribute(),
|
|
|
|
PatentTitle: patentTitles,
|
2021-12-24 12:00:18 +08:00
|
|
|
},
|
2022-01-26 10:34:29 +08:00
|
|
|
ResearchName: out.ResearchName,
|
|
|
|
Researchs: out.GetResearchAttribute(),
|
|
|
|
Introduce: out.Introduce,
|
2021-12-24 12:00:18 +08:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-12-24 15:28:46 +08:00
|
|
|
// Achievement 成果信息
|
2021-12-24 12:00:18 +08:00
|
|
|
func (c *Expert) Achievement(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
2021-12-24 15:28:46 +08:00
|
|
|
uids, err := c.user(id)
|
2021-12-24 12:00:18 +08:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-12-27 10:34:06 +08:00
|
|
|
return achievement(uids, page, pageSize)
|
2021-12-24 12:00:18 +08:00
|
|
|
}
|
|
|
|
|
2021-12-24 15:28:46 +08:00
|
|
|
// Project 项目信息
|
|
|
|
func (c *Expert) Project(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
|
|
|
// 查询专家身份下用户信息
|
|
|
|
uids, err := c.user(id)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-12-27 10:34:06 +08:00
|
|
|
return project(uids, page, pageSize)
|
2021-12-24 15:28:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Patent 专利信息
|
|
|
|
func (c *Expert) Patent(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
|
|
|
// 查询专家身份下用户信息
|
|
|
|
uids, err := c.user(id)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2022-01-04 15:04:37 +08:00
|
|
|
return patent(uids, page, pageSize)
|
2021-12-24 15:28:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Paper 论文信息
|
|
|
|
func (c *Expert) Paper(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
|
|
|
// 查询专家身份下用户信息
|
|
|
|
uids, err := c.user(id)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-12-27 10:34:06 +08:00
|
|
|
return paper(uids, page, pageSize)
|
2021-12-24 15:28:46 +08:00
|
|
|
}
|
|
|
|
|
2021-12-27 10:34:06 +08:00
|
|
|
// Cooperate 企业信息
|
|
|
|
func (c *Expert) Cooperate(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
2021-12-24 16:20:03 +08:00
|
|
|
// 查询专家身份下用户信息
|
|
|
|
uids, err := c.user(id)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-12-27 10:34:06 +08:00
|
|
|
return cooperate(uids, page, pageSize)
|
2021-12-24 16:20:03 +08:00
|
|
|
}
|
|
|
|
|
2021-12-27 10:34:06 +08:00
|
|
|
// CooperateDetail 公司企业详细信息
|
|
|
|
func (c *Expert) CooperateDetail(id uint64) (*CooperateDetailInfo, error) {
|
|
|
|
return cooperateDetail(id)
|
2021-12-24 16:20:03 +08:00
|
|
|
}
|
|
|
|
|
2021-12-24 12:00:18 +08:00
|
|
|
func NewExpert() ExpertHandle {
|
|
|
|
return func(session *session.Enterprise) *Expert {
|
|
|
|
return &Expert{session}
|
|
|
|
}
|
|
|
|
}
|