functiondefineaddlogic.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 FunctionDefineAddLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewFunctionDefineAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FunctionDefineAddLogic {
  17. return &FunctionDefineAddLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *FunctionDefineAddLogic) FunctionDefineAdd(req *types.FunctionDefineReq) (resp *types.Reply, err error) {
  24. // todo: add your logic here and delete this line
  25. resp = &types.Reply{}
  26. goodsResp, err := service.GoodsCenterRpc.FunctionDefineAdd(l.ctx, &pb.FunctionDefineReq{
  27. GoodsCode: req.Goods_code,
  28. FunctionCodeArr: req.Function_code_arr,
  29. Name: req.Name,
  30. Appid: req.AppId,
  31. })
  32. if goodsResp.ErrorMsg != "" {
  33. resp.Error_msg = goodsResp.ErrorMsg
  34. resp.Error_code = -1
  35. l.Error(fmt.Sprintf("%+v", req), resp.Error_msg)
  36. }
  37. resp.Data = map[string]interface{}{
  38. "status": goodsResp.Status,
  39. }
  40. return
  41. }