package logic import ( "context" "fusenapi/model/gmodel" "fusenapi/utils/auth" "fusenapi/utils/basic" "fusenapi/server/data-transfer/internal/svc" "fusenapi/server/data-transfer/internal/types" "github.com/zeromicro/go-zero/core/logx" ) type GetQrCodeSetListLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewGetQrCodeSetListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetQrCodeSetListLogic { return &GetQrCodeSetListLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, } } // 获取二维码配置列表 func (l *GetQrCodeSetListLogic) GetQrCodeSetList(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) { if userinfo.GetIdType() != auth.IDTYPE_User { return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first") } qrCodeModel := gmodel.NewFsQrcodeSetModel(l.svcCtx.MysqlConn) qrCodeList, err := qrCodeModel.GetAll(l.ctx) if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get qrcode list") } list := make([]types.GetQrCodeSetListRsp, 0, len(qrCodeList)) for _, v := range qrCodeList { list = append(list, types.GetQrCodeSetListRsp{ Id: v.Id, Name: *v.Name, }) } return resp.SetStatusWithMessage(basic.CodeOK, "success", list) }