goodsgetlogic.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package logic
  2. import (
  3. "context"
  4. "fmt"
  5. "bp.jydev.jianyu360.cn/BaseService/goodsCenter/rpc/pb"
  6. "bp.jydev.jianyu360.cn/BaseService/goodsCenter/public/service"
  7. "bp.jydev.jianyu360.cn/BaseService/goodsCenter/api/internal/svc"
  8. "bp.jydev.jianyu360.cn/BaseService/goodsCenter/api/internal/types"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type GoodsGetLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewGoodsGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsGetLogic {
  17. return &GoodsGetLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *GoodsGetLogic) GoodsGet(req *types.GoodsIdReq) (resp *types.Reply, err error) {
  24. // todo: add your logic here and delete this line
  25. resp = &types.Reply{}
  26. goodsResp, err := service.GoodsCenterRpc.GoodsGet(l.ctx, &pb.GoodsGetReq{
  27. Appid: req.AppId,
  28. Id: req.Id,
  29. })
  30. if goodsResp.ErrorMsg != "" {
  31. resp.Error_msg = goodsResp.ErrorMsg
  32. resp.Error_code = -1
  33. l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
  34. } else {
  35. resp.Data = &types.GoodsAddReq{
  36. Name: goodsResp.Name,
  37. Code: goodsResp.Code,
  38. Stand_classify_code: goodsResp.StandClassifyCode,
  39. Business_classify_code: goodsResp.BusinessClassifyCode,
  40. Business_id: goodsResp.BusinessId,
  41. Pc_landpage: goodsResp.PcLandpage,
  42. Wx_landpage: goodsResp.WxLandpage,
  43. App_landpage: goodsResp.AppLandpage,
  44. Logo: goodsResp.Logo,
  45. Introduce_img_1: goodsResp.IntroduceImg_1,
  46. Introduce_img_2: goodsResp.IntroduceImg_2,
  47. Introduce_img_3: goodsResp.IntroduceImg_3,
  48. Detail: goodsResp.Detail,
  49. Status: goodsResp.Status,
  50. Create_persion: goodsResp.CreatePersion,
  51. Update_person: goodsResp.UpdatePerson,
  52. Describe: goodsResp.Describes,
  53. Label: goodsResp.Label,
  54. Attributes: goodsResp.Attributes,
  55. }
  56. }
  57. return
  58. }