71 lines
1.9 KiB
Go
71 lines
1.9 KiB
Go
package search
|
|
|
|
import (
|
|
"SciencesServer/app/api/website/model"
|
|
"SciencesServer/app/basic/config"
|
|
"SciencesServer/app/basic/controller"
|
|
model2 "SciencesServer/app/common/model"
|
|
"SciencesServer/app/service"
|
|
config2 "SciencesServer/config"
|
|
)
|
|
|
|
type (
|
|
AchievementInfo struct {
|
|
ID string `json:"id"`
|
|
*model.TechnologyAchievementInfo
|
|
Customers []string `json:"customers"`
|
|
Industrys []string `json:"industrys"`
|
|
Keywords []string `json:"keywords"`
|
|
}
|
|
)
|
|
|
|
func achievementSearch(page, pageSize int, keyword, industry string, params map[string]interface{}) (*controller.ReturnPages, error) {
|
|
manage := service.NewESAchievement(
|
|
service.WithAchievementTitle(keyword),
|
|
service.WithAchievementKeyword(keyword),
|
|
)
|
|
if industry != "" {
|
|
service.WithAchievementIndustry(industry)(manage)
|
|
}
|
|
out, count, err := manage.Search(page, pageSize)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ids := make([]uint64, 0)
|
|
|
|
for _, v := range out.([]interface{}) {
|
|
val := v.(*service.ESAchievement)
|
|
ids = append(ids, val.ID)
|
|
}
|
|
if len(ids) <= 0 {
|
|
return nil, nil
|
|
}
|
|
mTechnologyAchievement := model.NewTechnologyAchievement()
|
|
|
|
achievements := make([]*model.TechnologyAchievementInfo, 0)
|
|
|
|
if achievements, err = mTechnologyAchievement.Achievement(model2.NewWhereIn("a.id", ids)); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
list := make([]*AchievementInfo, 0)
|
|
|
|
for _, v := range achievements {
|
|
_industrys := make([]string, 0)
|
|
|
|
for _, v := range v.GetIndustryAttribute() {
|
|
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "/").Value)
|
|
}
|
|
|
|
v.Image.Image = v.Image.Analysis(config2.SystemConfig[config2.SysImageDomain])
|
|
|
|
list = append(list, &AchievementInfo{
|
|
ID: v.GetEncodeID(), TechnologyAchievementInfo: v,
|
|
Customers: v.GetCustomerAttribute(),
|
|
Industrys: _industrys, Keywords: v.GetKeywordAttribute(),
|
|
})
|
|
}
|
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
|
}
|