45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
|
package logic
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fusenapi/model"
|
||
|
"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() (resp *types.Response) {
|
||
|
qrCodeModel := model.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)
|
||
|
}
|