package logic import ( "context" "fmt" "git.i2edu.net/i2/i2-bill-erp/internal/svc" "git.i2edu.net/i2/i2-bill-erp/transform" "git.i2edu.net/i2/go-zero/core/logx" ) type Options struct { Value interface{} `json:"value"` Text string `json:"text"` } type LoadOptionsetLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewLoadOptionsetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LoadOptionsetLogic { return &LoadOptionsetLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } func (l *LoadOptionsetLogic) LoadOptionset(in *transform.OptionsetReq) (*transform.OptionsetRes, error) { var options struct { Value []*Options `json:"value"` } l.svcCtx.SqlConn.QueryRowPartial(&options, "select value from sys_optionset where code=?", in.Code) optionset := make(map[string]string) for _, opt := range options.Value { value := fmt.Sprintf("%v", opt.Value) optionset[value] = opt.Text } return &transform.OptionsetRes{MapList: optionset}, nil }