showsearchlogic.go 2.8 KB

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