feat:完善项目信息
This commit is contained in:
@ -5,8 +5,10 @@ import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -25,6 +27,14 @@ type (
|
||||
*model.TechnologyAchievementInfo
|
||||
Industrys []string `json:"industrys"`
|
||||
}
|
||||
// AchievementMatchInfo 成果匹配信息
|
||||
AchievementMatchInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.TechnologyAchievementInstance
|
||||
Industrys []string `json:"industrys"`
|
||||
Keywords []string `json:"keywords"`
|
||||
Customers []string `json:"customers"`
|
||||
}
|
||||
// AchievementDetail 成果详情
|
||||
AchievementDetail struct {
|
||||
ID string `json:"id"`
|
||||
@ -69,6 +79,53 @@ func (c *Achievement) Instance(status, page, pageSize int) (*controller.ReturnPa
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Match 匹配信息
|
||||
func (c *Achievement) Match(title string, industrys, keywords []string) ([]*AchievementMatchInfo, error) {
|
||||
params := strings.Join([]string{
|
||||
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
|
||||
}, ",")
|
||||
achievement := service.NewESAchievement(
|
||||
service.WithAchievementTitle(params),
|
||||
service.WithAchievementIndustry(params),
|
||||
service.WithAchievementKeyword(params),
|
||||
)
|
||||
out, err := achievement.Search(0, 0)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ids := make([]uint64, 0)
|
||||
|
||||
for _, v := range out.([]interface{}) {
|
||||
val := v.(*service.ESAchievement)
|
||||
ids = append(ids, val.ID)
|
||||
}
|
||||
achievements := make([]*model.TechnologyAchievementInstance, 0)
|
||||
|
||||
mTechnologyAchievement := model.NewTechnologyAchievement()
|
||||
|
||||
if achievements, err = mTechnologyAchievement.Instance(model2.NewWhereIn("a.id", ids),
|
||||
model2.NewWhere("a.shelf_status", model2.ShelfStatusForUp)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*AchievementMatchInfo, 0)
|
||||
|
||||
for _, v := range achievements {
|
||||
mTechnologyAchievement.Industry = v.Industry
|
||||
mTechnologyAchievement.Keyword = v.Keyword
|
||||
mTechnologyAchievement.Customer = v.Customer
|
||||
|
||||
list = append(list, &AchievementMatchInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
TechnologyAchievementInstance: v,
|
||||
Industrys: mTechnologyAchievement.GetIndustryAttribute(),
|
||||
Keywords: mTechnologyAchievement.GetKeywordAttribute(),
|
||||
Customers: mTechnologyAchievement.GetCustomerAttribute(),
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// Detail 详情信息
|
||||
func (c *Achievement) Detail(id uint64) (*AchievementDetail, error) {
|
||||
mTechnologyAchievement := model.NewTechnologyAchievement()
|
||||
|
Reference in New Issue
Block a user