feat:完善项目信息
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -18,10 +19,40 @@ type Expert struct {
|
||||
|
||||
type ExpertHandle func(session *session.Enterprise, local string) *Expert
|
||||
|
||||
type ExpertInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.ManageExpertInfo
|
||||
Industrys []string `json:"industrys"`
|
||||
type (
|
||||
// ExpertInfo 专家信息
|
||||
ExpertInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.ManageExpertInfo
|
||||
Industrys []string `json:"industrys"`
|
||||
}
|
||||
// ExpertMatchInfo 专家匹配信息
|
||||
ExpertMatchInfo struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
School string `json:"school"`
|
||||
Major string `json:"major"`
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
PatentTitles []string `json:"patent_titles"`
|
||||
}
|
||||
// ExpertDetailInfo 专家详细信息
|
||||
ExpertDetailInfo struct {
|
||||
ExpertMatchInfo
|
||||
Researchs []string `json:"researchs"`
|
||||
Introduce string `json:"introduce"`
|
||||
}
|
||||
)
|
||||
|
||||
// user 用户信息
|
||||
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
|
||||
}
|
||||
|
||||
// research 研究机构专家信息
|
||||
@ -131,6 +162,137 @@ func (c *Expert) Instance(name, mobile string, page, pageSize int) (*controller.
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Match 匹配信息
|
||||
func (c *Expert) Match(title string, industrys, keywords []string) ([]*ExpertMatchInfo, error) {
|
||||
params := strings.Join([]string{
|
||||
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
|
||||
}, ",")
|
||||
|
||||
manage := service.NewESManage(
|
||||
service.WithManageIdentity(config.TenantUserIdentityForExpert),
|
||||
)
|
||||
out, err := manage.Search(0, 0, map[string]interface{}{
|
||||
"title": params, "industry": params, "keyword": params, "research": params,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ids := make([]uint64, 0)
|
||||
|
||||
for _, v := range out.([]interface{}) {
|
||||
val := v.(*service.ESManage)
|
||||
ids = append(ids, val.ID)
|
||||
}
|
||||
mManageExpert := model.NewManageExpert()
|
||||
|
||||
experts := make([]*model.ManageExpertInstanceInfo, 0)
|
||||
|
||||
if experts, err = mManageExpert.Instance(3, model2.NewWhereIn("e.id", ids)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*ExpertMatchInfo, 0)
|
||||
|
||||
for _, v := range experts {
|
||||
list = append(list, &ExpertMatchInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
Name: v.Name,
|
||||
School: v.School,
|
||||
Major: v.Major,
|
||||
Industrys: v.GetIndustryAttribute(),
|
||||
Keywords: v.GetKeywordAttribute(),
|
||||
PatentTitles: strings.Split(v.PatentTitle, "&&"),
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Expert) Detail(id uint64) (*ExpertDetailInfo, error) {
|
||||
mManageExpert := model.NewManageExpert()
|
||||
out, err := mManageExpert.Detail(3, id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ExpertDetailInfo{
|
||||
ExpertMatchInfo: ExpertMatchInfo{
|
||||
ID: out.GetEncodeID(),
|
||||
Name: out.Name,
|
||||
School: out.School,
|
||||
Major: out.Major,
|
||||
Industrys: out.GetIndustryAttribute(),
|
||||
Keywords: out.GetKeywordAttribute(),
|
||||
PatentTitles: strings.Split(out.PatentTitle, "&&"),
|
||||
},
|
||||
Researchs: out.GetResearchAttribute(),
|
||||
Introduce: out.Introduce,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Achievement 成果信息
|
||||
func (c *Expert) Achievement(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
uids, err := c.user(id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return achievement(uids, page, pageSize)
|
||||
}
|
||||
|
||||
// Project 项目信息
|
||||
func (c *Expert) Project(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
// 查询专家身份下用户信息
|
||||
uids, err := c.user(id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return project(uids, page, pageSize)
|
||||
}
|
||||
|
||||
// Patent 专利信息
|
||||
func (c *Expert) Patent(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
// 查询专家身份下用户信息
|
||||
uids, err := c.user(id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return patent(uids, page, pageSize)
|
||||
}
|
||||
|
||||
// Paper 论文信息
|
||||
func (c *Expert) Paper(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
// 查询专家身份下用户信息
|
||||
uids, err := c.user(id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return paper(uids, page, pageSize)
|
||||
}
|
||||
|
||||
// Cooperate 企业信息
|
||||
func (c *Expert) Cooperate(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
// 查询专家身份下用户信息
|
||||
uids, err := c.user(id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return cooperate(uids, page, pageSize)
|
||||
}
|
||||
|
||||
// CooperateDetail 公司企业详细信息
|
||||
func (c *Expert) CooperateDetail(id uint64) (*CooperateDetailInfo, error) {
|
||||
return cooperateDetail(id)
|
||||
}
|
||||
|
||||
func NewExpert() ExpertHandle {
|
||||
return func(session *session.Enterprise, local string) *Expert {
|
||||
return &Expert{
|
||||
|
Reference in New Issue
Block a user