get_erp_optionset_logic.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package sys_optionset
  2. import (
  3. "context"
  4. "errors"
  5. "git.i2edu.net/i2/i2-bill-erp/transform"
  6. "git.i2edu.net/i2/i2-bill-api/internal/svc"
  7. "git.i2edu.net/i2/i2-bill-api/internal/types"
  8. "git.i2edu.net/i2/go-zero/core/logx"
  9. )
  10. type GetErpOptionsetLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewGetErpOptionsetLogic(ctx context.Context, svcCtx *svc.ServiceContext) GetErpOptionsetLogic {
  16. return GetErpOptionsetLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *GetErpOptionsetLogic) GetErpOptionset(req string) (*types.Response, error) {
  23. // todo: add your logic here and delete this line
  24. if req == "" {
  25. return nil, errors.New("请输入字典编码")
  26. }
  27. ctx := context.Background()
  28. res, err := l.svcCtx.Transformer.GetErpOptionset(ctx, &transform.OptionCode{Code: req})
  29. var msg string
  30. var code = 200
  31. var data = res
  32. if err != nil {
  33. code = 500
  34. msg = err.Error()
  35. data = nil
  36. }
  37. return &types.Response{Code: code, Msg: msg, Data: data}, nil
  38. }