addsearchlogic.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package logic
  2. import (
  3. "context"
  4. "jyBXBase/rpc/bxbase"
  5. IC "jyBXBase/rpc/init"
  6. "log"
  7. "strings"
  8. "time"
  9. "jyBXBase/rpc/internal/svc"
  10. "github.com/zeromicro/go-zero/core/logx"
  11. )
  12. type AddSearchLogic struct {
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. logx.Logger
  16. }
  17. func NewAddSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddSearchLogic {
  18. return &AddSearchLogic{
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. Logger: logx.WithContext(ctx),
  22. }
  23. }
  24. // 获取收藏列表
  25. func (l *AddSearchLogic) AddSearch(in *bxbase.AddSearchReq) (res *bxbase.CommonRes, err error) {
  26. // todo: add your logic here and delete this line
  27. res = new(bxbase.CommonRes)
  28. newData := make(map[string]interface{})
  29. if in.UserId == "" {
  30. res.ErrCode = 1
  31. res.ErrMsg = "用户未登录"
  32. return
  33. }
  34. log.Println("添加收藏列表:", in)
  35. in.NotKey = strings.Replace(in.NotKey, " ", ",", -1)
  36. in.Keywords = strings.Replace(in.Keywords, " ", ",", -1)
  37. newData["keywords"] = in.Keywords
  38. newData["type"] = in.Type
  39. newData["publish_time"] = in.PublishTime
  40. newData["area"] = in.Area
  41. newData["city"] = in.City
  42. newData["subtype"] = in.Subtype
  43. newData["min_price"] = in.MinPrice
  44. newData["max_price"] = in.MaxPrice
  45. newData["industry"] = in.Industry
  46. newData["select_type"] = in.SelectType
  47. newData["buyer_class"] = in.BuyerClass
  48. newData["buyer_tel"] = in.HasBuyerTel
  49. newData["winner_tel"] = in.HasWinnerTel
  50. newData["file_exists"] = in.FileExists
  51. newData["not_key"] = in.NotKey
  52. newData["tabular_flag"] = in.TabularFlag
  53. newData["creation_time"] = time.Now().Unix()
  54. newData["user_id"] = in.UserId
  55. IC.Mgo.Save("search_condition", newData)
  56. return
  57. }