showsearchlogic.go 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "context"
  5. "jyBXBase/rpc/bxcollection/bxcol"
  6. "jyBXBase/rpc/bxcollection/internal/svc"
  7. "jyBXBase/rpc/bxcollection/model"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type ShowSearchLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewShowSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowSearchLogic {
  16. return &ShowSearchLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. // 获取收藏列表
  23. func (l *ShowSearchLogic) ShowSearch(in *bxcol.ShowSearchReq) (res *bxcol.ShowSearchRes, err error) {
  24. // todo: add your logic here and delete this line
  25. var (
  26. data []*bxcol.ListSearchRes
  27. )
  28. res = new(bxcol.ShowSearchRes)
  29. if in.UserId == "" {
  30. res.ErrCode = 1
  31. res.ErrMsg = "用户未登录"
  32. return res, nil
  33. }
  34. query := map[string]interface{}{
  35. "user_id": in.UserId,
  36. "type": in.Type,
  37. }
  38. allSearch, b := model.Mgo.Find("search_condition", query, `{"creation_time":-1}`, "", false, -1, -1)
  39. if !b {
  40. res.ErrCode = 1
  41. res.ErrMsg = "用户搜索信息查询失败"
  42. return res, nil
  43. }
  44. if allSearch != nil {
  45. for _, vlu := range *allSearch {
  46. var listSearch bxcol.ListSearchRes
  47. listSearch.Id = common.InterfaceToStr(vlu["_id"])
  48. listSearch.Searchvalue = common.InterfaceToStr(vlu["keywords"])
  49. listSearch.Publishtime = common.InterfaceToStr(vlu["publish_time"])
  50. listSearch.Area = common.InterfaceToStr(vlu["area"])
  51. listSearch.City = common.InterfaceToStr(vlu["city"])
  52. listSearch.Subtype = common.InterfaceToStr(vlu["subtype"])
  53. listSearch.Minprice = common.InterfaceToStr(vlu["min_price"])
  54. listSearch.Maxprice = common.InterfaceToStr(vlu["max_price"])
  55. listSearch.Industry = common.InterfaceToStr(vlu["industry"])
  56. listSearch.SelectType = common.InterfaceToStr(vlu["select_type"])
  57. listSearch.Buyerclass = common.InterfaceToStr(vlu["buyer_class"])
  58. listSearch.Buyertel = common.InterfaceToStr(vlu["buyer_tel"])
  59. listSearch.Winnertel = common.InterfaceToStr(vlu["winner_tel"])
  60. listSearch.FileExists = common.InterfaceToStr(vlu["file_exists"])
  61. listSearch.NotKey = common.InterfaceToStr(vlu["not_key"])
  62. listSearch.Tabularflag = common.InterfaceToStr(vlu["tabular_flag"])
  63. //ppa,buyer,winner,agency
  64. if (listSearch.SelectType != "title,content" && listSearch.SelectType != "title" && listSearch.SelectType != "content") ||
  65. (listSearch.Publishtime != "lately-7" && listSearch.Publishtime != "thisyear" && listSearch.Publishtime != "lately-30") ||
  66. listSearch.City != "" || listSearch.NotKey != "" || listSearch.Winnertel != "" || listSearch.Buyertel != "" || listSearch.Buyerclass != "" {
  67. listSearch.IsPay = true
  68. }
  69. data = append(data, &listSearch)
  70. }
  71. }
  72. res.Data = data
  73. return res, nil
  74. }