addsearchlogic.go 1.6 KB

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