61 lines
1.6 KiB
Go
61 lines
1.6 KiB
Go
package search
|
|
|
|
import (
|
|
"SciencesServer/app/api/website/model"
|
|
"SciencesServer/app/basic/controller"
|
|
model2 "SciencesServer/app/common/model"
|
|
"SciencesServer/app/service"
|
|
)
|
|
|
|
type (
|
|
// PatentInfo 专利信息
|
|
PatentInfo struct {
|
|
ID string `json:"id"`
|
|
Kind model2.SysParentKind `json:"kind"`
|
|
Title string `json:"title"`
|
|
ApplyAt string `json:"apply_at"`
|
|
Description string `json:"description"`
|
|
}
|
|
)
|
|
|
|
// searchPatent 专利搜索
|
|
func searchPatent(page, pageSize int, keyword, industry string, params map[string]interface{}) (*controller.ReturnPages, error) {
|
|
manage := service.NewESPatent(
|
|
service.WithPatentTitle(keyword),
|
|
)
|
|
if industry != "" {
|
|
service.WithPatentIndustry(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.ESPatent)
|
|
ids = append(ids, val.ID)
|
|
}
|
|
if len(ids) <= 0 {
|
|
return nil, nil
|
|
}
|
|
mTechnologyPatent := model.NewTechnologyPatent()
|
|
|
|
patents := make([]*model2.SysPatent, 0)
|
|
|
|
if err = model2.ScanFields(mTechnologyPatent.TechnologyPatent, &patents, []string{"id", "kind", "title", "apply_at", "description"},
|
|
&model2.ModelWhereOrder{Where: model2.NewWhereIn("id", ids)}); err != nil {
|
|
return nil, err
|
|
}
|
|
list := make([]*PatentInfo, 0)
|
|
|
|
for _, v := range patents {
|
|
|
|
list = append(list, &PatentInfo{
|
|
ID: v.GetEncodeID(), Kind: v.Kind, Title: v.Title, ApplyAt: v.ApplyAt, Description: v.Description,
|
|
})
|
|
}
|
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
|
}
|