audit_result.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/app/admin/main/tv/model"
  6. "go-common/library/database/elastic"
  7. "go-common/library/log"
  8. )
  9. // ArcES treats the ugc index request and call the ES to get the result
  10. func (d *Dao) ArcES(c context.Context, req *model.ReqArcES) (data *model.EsUgcResult, err error) {
  11. var (
  12. cfg = d.c.Cfg.EsIdx.UgcIdx
  13. r = d.esClient.NewRequest(cfg.Business).Index(cfg.Index).WhereEq("deleted", 0)
  14. )
  15. if req.Valid != "" {
  16. r = r.WhereEq("valid", req.Valid)
  17. }
  18. if req.AID != "" {
  19. r = r.WhereEq("aid", req.AID)
  20. }
  21. if req.Result != "" {
  22. r = r.WhereEq("result", req.Result)
  23. }
  24. if len(req.Typeids) != 0 {
  25. r = r.WhereIn("typeid", req.Typeids)
  26. }
  27. if req.Title != "" {
  28. r = r.WhereLike([]string{"title"}, []string{req.Title}, true, elastic.LikeLevelMiddle)
  29. }
  30. if len(req.Mids) != 0 {
  31. r = r.WhereIn("mid", req.Mids)
  32. }
  33. r.Ps(req.Ps).Pn(int(req.Pn))
  34. if req.MtimeOrder != "" {
  35. r = r.Order("mtime", req.MtimeSort())
  36. }
  37. if req.PubtimeOrder != "" {
  38. r = r.Order("pubtime", req.PubtimeSort())
  39. }
  40. if err = r.Scan(c, &data); err != nil {
  41. log.Error("ArcES:Scan params(%s) error(%v)", r.Params(), err)
  42. return
  43. }
  44. if data == nil || data.Page == nil {
  45. err = fmt.Errorf("data or data.Page nil")
  46. log.Error("ArcES params(%s) error(%v)", r.Params(), err)
  47. return
  48. }
  49. return
  50. }