limitSearchContentLogic.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package logic
  2. import (
  3. "context"
  4. "jyBXCore/rpc/type/bxcore"
  5. "net/http"
  6. "jyBXCore/api/internal/svc"
  7. "jyBXCore/api/internal/types"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type LimitSearchContentLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. r *http.Request
  15. }
  16. func NewLimitSearchContentLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request) *LimitSearchContentLogic {
  17. return &LimitSearchContentLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. r: r,
  22. }
  23. }
  24. func (l *LimitSearchContentLogic) LimitSearchContent(req *types.SearchLimitReq) (resp *types.CommonResp, err error) {
  25. res, err := l.svcCtx.BxCore.SearchLimit(l.ctx, &bxcore.SearchLimitReq{
  26. Appid: req.AppId,
  27. TimeOut: req.TimeOut,
  28. Count: req.Count,
  29. Flag: req.Flag,
  30. Percentage: req.Percentage,
  31. UserId: l.r.Header.Get("userId"),
  32. SearchType: req.SearchType,
  33. })
  34. if err != nil {
  35. return &types.CommonResp{
  36. Err_code: res.ErrCode,
  37. Err_msg: res.ErrMsg,
  38. Data: nil,
  39. }, nil
  40. }
  41. return &types.CommonResp{
  42. Err_code: res.ErrCode,
  43. Err_msg: res.ErrMsg,
  44. Data: res.Data,
  45. }, nil
  46. }