feat:优化信息,完善es查询,完善网站首页公司信息查询
This commit is contained in:
@ -13,6 +13,7 @@ func (*ES) Create(c *gin.Context) {
|
|||||||
ID uint64 `json:"id" form:"id"`
|
ID uint64 `json:"id" form:"id"`
|
||||||
Identity int `json:"identity" form:"identity"`
|
Identity int `json:"identity" form:"identity"`
|
||||||
Title string `json:"title" form:"title"`
|
Title string `json:"title" form:"title"`
|
||||||
|
Industry string `json:"industry" form:"industry"`
|
||||||
Keyword string `json:"keyword" form:"keyword"`
|
Keyword string `json:"keyword" form:"keyword"`
|
||||||
Research string `json:"research" form:"research"`
|
Research string `json:"research" form:"research"`
|
||||||
}{}
|
}{}
|
||||||
@ -20,12 +21,18 @@ func (*ES) Create(c *gin.Context) {
|
|||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
manage := service.NewESManage(
|
//manage := service.NewESManage(
|
||||||
service.WithManageID(form.ID),
|
// service.WithManageID(form.ID),
|
||||||
service.WithManageIdentity(form.Identity),
|
// service.WithManageIdentity(form.Identity),
|
||||||
service.WithManageTitle(form.Title),
|
// service.WithManageTitle(form.Title),
|
||||||
service.WithManageKeyword(form.Keyword),
|
// service.WithManageKeyword(form.Keyword),
|
||||||
service.WithManageResearch(form.Research),
|
// service.WithManageResearch(form.Research),
|
||||||
|
//)
|
||||||
|
manage := service.NewESPatent(
|
||||||
|
service.WithPatentID(form.ID),
|
||||||
|
//service.WithManageIdentity(form.Identity),
|
||||||
|
service.WithPatentTitle(form.Title),
|
||||||
|
service.WithPatentIndustry(form.Industry),
|
||||||
)
|
)
|
||||||
api.APIResponse(manage.Create())(c)
|
api.APIResponse(manage.Create())(c)
|
||||||
}
|
}
|
||||||
@ -40,11 +47,15 @@ func (*ES) Search(c *gin.Context) {
|
|||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
manage := service.NewESManage(service.WithManageIdentity(form.Identity),
|
//manage := service.NewESManage(service.WithManageIdentity(form.Identity),
|
||||||
service.WithManageTitle(form.Param),
|
// service.WithManageTitle(form.Param),
|
||||||
service.WithManageIndustry(form.Industry),
|
// service.WithManageIndustry(form.Industry),
|
||||||
service.WithManageKeyword(form.Param),
|
// service.WithManageKeyword(form.Param),
|
||||||
service.WithManageResearch(form.Param))
|
// service.WithManageResearch(form.Param))
|
||||||
data, err := manage.Search(1, 1)
|
manage := service.NewESPatent(
|
||||||
|
service.WithPatentTitle(form.Param),
|
||||||
|
service.WithPatentIndustry(form.Industry),
|
||||||
|
)
|
||||||
|
data, err := manage.Search(1, 10)
|
||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
@ -117,9 +117,6 @@ func (c *Search) Launch(identity int, param, industry string, page, pageSize int
|
|||||||
ids := make([]uint64, 0)
|
ids := make([]uint64, 0)
|
||||||
|
|
||||||
for _, v := range out.([]*service.ESManage) {
|
for _, v := range out.([]*service.ESManage) {
|
||||||
if v.Identity != identity {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
ids = append(ids, v.ID)
|
ids = append(ids, v.ID)
|
||||||
}
|
}
|
||||||
handle, has := searchIdentityHandle[identity]
|
handle, has := searchIdentityHandle[identity]
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"SciencesServer/app/api/website/model"
|
"SciencesServer/app/api/website/model"
|
||||||
"SciencesServer/app/basic/controller"
|
"SciencesServer/app/basic/controller"
|
||||||
model2 "SciencesServer/app/common/model"
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/service"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
@ -28,27 +29,38 @@ type (
|
|||||||
// Instance 查询信息
|
// Instance 查询信息
|
||||||
func (c *Patent) Instance(title, industry string, page, pageSize int) (*controller.ReturnPages, error) {
|
func (c *Patent) Instance(title, industry string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
// TODO:缺少会员判断标准
|
// TODO:缺少会员判断标准
|
||||||
mSysPatent := model.NewSysPatent()
|
// ES标准判定
|
||||||
|
s := service.NewESPatent(
|
||||||
|
service.WithPatentTitle(title),
|
||||||
|
service.WithPatentIndustry(industry),
|
||||||
|
)
|
||||||
|
out, err := s.Search(page, pageSize)
|
||||||
|
|
||||||
where := make([]*model2.ModelWhere, 0)
|
list := make([]*PatentInfo, 0)
|
||||||
|
|
||||||
if title != "" {
|
|
||||||
where = append(where, model2.NewWhereLike("p.title", title))
|
|
||||||
}
|
|
||||||
if industry != "" {
|
|
||||||
where = append(where, model2.NewWhereCondition("c.industry_detail", "LIKE",
|
|
||||||
"%"+fmt.Sprintf(`"%v`, industry)+"%"))
|
|
||||||
}
|
|
||||||
var count int64
|
var count int64
|
||||||
|
|
||||||
out, err := mSysPatent.Patent(page, pageSize, &count, where...)
|
fmt.Println(out)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
} else if out == nil {
|
||||||
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
}
|
}
|
||||||
list := make([]*PatentInfo, 0)
|
mSysPatent := model.NewSysPatent()
|
||||||
|
|
||||||
for _, v := range out {
|
ids := make([]uint64, 0)
|
||||||
|
|
||||||
|
for _, v := range out.([]interface{}) {
|
||||||
|
val := v.(*service.ESPatent)
|
||||||
|
ids = append(ids, val.ID)
|
||||||
|
}
|
||||||
|
ret := make([]*model.SysPatentInfo, 0)
|
||||||
|
|
||||||
|
if ret, err = mSysPatent.Patent(page, pageSize, &count, model2.NewWhereIn("p.id", ids)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, v := range ret {
|
||||||
list = append(list, &PatentInfo{
|
list = append(list, &PatentInfo{
|
||||||
ID: v.GetEncodeID(),
|
ID: v.GetEncodeID(),
|
||||||
SysPatentInfo: v,
|
SysPatentInfo: v,
|
||||||
|
@ -3,7 +3,9 @@ package service
|
|||||||
import (
|
import (
|
||||||
"SciencesServer/serve/es"
|
"SciencesServer/serve/es"
|
||||||
"SciencesServer/serve/logger"
|
"SciencesServer/serve/logger"
|
||||||
|
"SciencesServer/utils"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ESPatent struct {
|
type ESPatent struct {
|
||||||
@ -19,14 +21,30 @@ func (this *ESPatent) Index() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *ESPatent) Create() error {
|
func (this *ESPatent) Create() error {
|
||||||
|
if this.Industry != "" {
|
||||||
|
this.Title = this.Industry + " - " + this.Title
|
||||||
|
}
|
||||||
_bytes, _ := json.Marshal(this)
|
_bytes, _ := json.Marshal(this)
|
||||||
return es.Create(this.Index(), _bytes)
|
return es.Create(this.Index(), _bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ESPatent) Search(page, pageSize int, params map[string]interface{}) (interface{}, error) {
|
func (this *ESPatent) Search(page, pageSize int) (interface{}, error) {
|
||||||
|
mustParams := make(map[string]interface{}, 0)
|
||||||
|
shouldParams := make(map[string]interface{}, 0)
|
||||||
|
|
||||||
|
fmt.Println(utils.AnyToJSON(this))
|
||||||
|
|
||||||
|
if this.Title != "" {
|
||||||
|
shouldParams["title"] = this.Title
|
||||||
|
}
|
||||||
|
if this.Industry != "" {
|
||||||
|
mustParams["title"] = this.Industry
|
||||||
|
}
|
||||||
|
fmt.Println(mustParams)
|
||||||
|
fmt.Println(shouldParams)
|
||||||
out, err := es.Search(this, this.Index(), &es.SearchParams{
|
out, err := es.Search(this, this.Index(), &es.SearchParams{
|
||||||
MustParams: nil,
|
MustParams: mustParams,
|
||||||
ShouldParams: params,
|
ShouldParams: shouldParams,
|
||||||
}, page, pageSize)
|
}, page, pageSize)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user