2023-06-08 03:34:58 +00:00
|
|
|
package logic
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2023-06-12 09:00:37 +00:00
|
|
|
"fusenapi/model/gmodel"
|
|
|
|
"fusenapi/utils/auth"
|
2023-06-08 03:34:58 +00:00
|
|
|
"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,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取二维码配置列表
|
2023-07-21 07:20:18 +00:00
|
|
|
func (l *GetQrCodeSetListLogic) GetQrCodeSetList(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
2023-06-15 04:00:32 +00:00
|
|
|
if userinfo.GetIdType() != auth.IDTYPE_User {
|
|
|
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "please login first")
|
|
|
|
}
|
2023-06-12 09:00:37 +00:00
|
|
|
qrCodeModel := gmodel.NewFsQrcodeSetModel(l.svcCtx.MysqlConn)
|
2023-06-08 03:34:58 +00:00
|
|
|
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,
|
2023-06-12 09:00:37 +00:00
|
|
|
Name: *v.Name,
|
2023-06-08 03:34:58 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
return resp.SetStatusWithMessage(basic.CodeOK, "success", list)
|
|
|
|
}
|