findconsumerecordlogic.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package logic
  2. import (
  3. "context"
  4. "errors"
  5. "app.yhyue.com/moapp/jyResourcesCenter/rpc/internal/svc"
  6. "app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenter"
  7. "github.com/tal-tech/go-zero/core/logx"
  8. )
  9. type FindConsumeRecordLogic struct {
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. logx.Logger
  13. }
  14. func NewFindConsumeRecordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindConsumeRecordLogic {
  15. return &FindConsumeRecordLogic{
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. Logger: logx.WithContext(ctx),
  19. }
  20. }
  21. func (l *FindConsumeRecordLogic) FindConsumeRecord(in *resourcesCenter.RecordReq) (*resourcesCenter.ConsumeRecordRes, error) {
  22. // todo: add your logic here and delete this line
  23. if in.AccountId != "" && in.UserId != "" && in.PageSize != 0 && in.Page != 0 {
  24. recordArr, err := resourceManageService.FindConsumeRecord(in)
  25. if len(recordArr) == 0 && err != nil {
  26. return &resourcesCenter.ConsumeRecordRes{
  27. Code: 0,
  28. Message: "查询出错",
  29. Data: recordArr,
  30. }, err
  31. }
  32. return &resourcesCenter.ConsumeRecordRes{
  33. Code: 1,
  34. Message: "查询成功",
  35. Data: recordArr,
  36. }, nil
  37. } else {
  38. return &resourcesCenter.ConsumeRecordRes{
  39. Code: 0,
  40. Message: "缺少参数",
  41. Data: nil,
  42. }, errors.New("缺少参数")
  43. }
  44. }