findpreviewlogic.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jyResourcesCenter/api/internal/svc"
  4. "app.yhyue.com/moapp/jyResourcesCenter/api/internal/types"
  5. "app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenterclient"
  6. "context"
  7. "github.com/tal-tech/go-zero/core/logx"
  8. )
  9. type FindPreviewLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewFindPreviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) FindPreviewLogic {
  15. return FindPreviewLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *FindPreviewLogic) FindPreview(req types.PreviewReq) (*types.PreviewRes, error) {
  22. // todo: add your logic here and delete this line
  23. result := &types.PreviewRes{}
  24. lsi := l.svcCtx.ResourcesCenter
  25. resp, err := lsi.FindPreview(l.ctx, &resourcesCenterclient.PreviewReq{
  26. AccountId: req.AccountId,
  27. ResourceType: req.ResourceType,
  28. InfoId: req.InfoId,
  29. })
  30. if err != nil {
  31. return nil, err
  32. }
  33. result.Code = resp.Code
  34. result.Message = resp.Message
  35. result.DeductionNumb = resp.DeductionNumb
  36. result.RepeatNumb = resp.RepeatNumb
  37. return result, nil
  38. }