get_erp_optionset_logic.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package logic
  2. import (
  3. "context"
  4. "errors"
  5. "git.i2edu.net/i2/go-zero/core/stores/sqlx"
  6. "git.i2edu.net/i2/i2-bill-erp/model"
  7. "git.i2edu.net/i2/i2-bill-erp/internal/svc"
  8. "git.i2edu.net/i2/i2-bill-erp/transform"
  9. "git.i2edu.net/i2/go-zero/core/logx"
  10. )
  11. type GetErpOptionsetLogic struct {
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. logx.Logger
  15. }
  16. func NewGetErpOptionsetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetErpOptionsetLogic {
  17. return &GetErpOptionsetLogic{
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. Logger: logx.WithContext(ctx),
  21. }
  22. }
  23. func (l *GetErpOptionsetLogic) GetErpOptionset(in *transform.OptionCode) (*transform.Options, error) {
  24. // todo: add your logic here and delete this line
  25. code := in.Code
  26. if code == "" {
  27. return nil, errors.New("请输入code参数")
  28. }
  29. var optionSet = new(model.SysOptionset)
  30. sql := `select
  31. *
  32. from
  33. sys_optionset
  34. where
  35. sys_optionset.del_flag = 0
  36. and code = ?`
  37. err := l.svcCtx.SqlConn.QueryRow(optionSet, sql, code)
  38. if err != nil && err != sqlx.ErrNotFound {
  39. return nil, err
  40. }
  41. return &transform.Options{Code: optionSet.Code, Name: optionSet.Name, Value: optionSet.Value}, nil
  42. }