feat(app): update
This commit is contained in:
@ -70,7 +70,7 @@ func _connect() (c *elastic.Client) {
|
||||
}
|
||||
|
||||
// 创建记录
|
||||
func (*EsClient) Create(index, id string, model interface{}) (body string, success bool, msg string) {
|
||||
func (*EsClient) Create(index, id string, model any) (body string, success bool, msg string) {
|
||||
client := _connect()
|
||||
_, e := client.Index().Index(index).Id(id).BodyJson(model).Do(context.Background())
|
||||
if e != nil {
|
||||
@ -99,7 +99,7 @@ func (*EsClient) Exists(index, id string) (exists, success bool, msg string, e e
|
||||
}
|
||||
|
||||
// 更新记录
|
||||
func (*EsClient) Update(index, id string, model interface{}) (body string, success bool, msg string) {
|
||||
func (*EsClient) Update(index, id string, model any) (body string, success bool, msg string) {
|
||||
client := _connect()
|
||||
_, e := client.Update().Index(index).Id(id).Doc(model).Do(context.Background())
|
||||
if e != nil {
|
||||
@ -112,7 +112,7 @@ func (*EsClient) Update(index, id string, model interface{}) (body string, succe
|
||||
}
|
||||
|
||||
// 搜索
|
||||
func (*EsClient) Search(index string, key string, fields ...string) (body []interface{}, success bool, msg string) {
|
||||
func (*EsClient) Search(index string, key string, fields ...string) (body []any, success bool, msg string) {
|
||||
client := _connect()
|
||||
logs.Info("ES Search index =", index, " key =", key, " fields =", fields)
|
||||
var list []*elastic.WildcardQuery
|
||||
@ -165,7 +165,7 @@ type ESSort struct {
|
||||
}
|
||||
|
||||
// 搜索消息
|
||||
func (*EsClient) SearchMulti(index string, filter ESFilter, page, size int) (result interface{}, success bool, msg string) {
|
||||
func (*EsClient) SearchMulti(index string, filter ESFilter, page, size int) (result any, success bool, msg string) {
|
||||
client := _connect()
|
||||
var list []elastic.Query
|
||||
for _, item := range filter.Queries {
|
||||
@ -217,14 +217,14 @@ func (*EsClient) SearchMulti(index string, filter ESFilter, page, size int) (res
|
||||
if e != nil {
|
||||
return
|
||||
}
|
||||
var body []interface{}
|
||||
var body []any
|
||||
for _, item := range res.Hits.Hits {
|
||||
b, _ := item.Source.MarshalJSON()
|
||||
m := make(map[string]interface{})
|
||||
m := make(map[string]any)
|
||||
_ = json.Unmarshal(b, &m)
|
||||
body = append(body, m)
|
||||
}
|
||||
result = map[string]interface{}{
|
||||
result = map[string]any{
|
||||
"Status": res.Status,
|
||||
"Total": res.Hits.TotalHits,
|
||||
"List": body,
|
||||
|
||||
Reference in New Issue
Block a user