feat:优化信息,完善es查询,完善网站首页公司信息查询
This commit is contained in:
@ -3,7 +3,9 @@ package service
|
||||
import (
|
||||
"SciencesServer/serve/es"
|
||||
"SciencesServer/serve/logger"
|
||||
"SciencesServer/utils"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ESPatent struct {
|
||||
@ -19,14 +21,30 @@ func (this *ESPatent) Index() string {
|
||||
}
|
||||
|
||||
func (this *ESPatent) Create() error {
|
||||
if this.Industry != "" {
|
||||
this.Title = this.Industry + " - " + this.Title
|
||||
}
|
||||
_bytes, _ := json.Marshal(this)
|
||||
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{
|
||||
MustParams: nil,
|
||||
ShouldParams: params,
|
||||
MustParams: mustParams,
|
||||
ShouldParams: shouldParams,
|
||||
}, page, pageSize)
|
||||
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user