fix
This commit is contained in:
@@ -2,7 +2,8 @@ package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fusenapi/model"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
"fusenapi/server/data-transfer/internal/svc"
|
||||
@@ -26,8 +27,8 @@ func NewGetQrCodeSetListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
|
||||
}
|
||||
|
||||
// 获取二维码配置列表
|
||||
func (l *GetQrCodeSetListLogic) GetQrCodeSetList() (resp *types.Response) {
|
||||
qrCodeModel := model.NewFsQrcodeSetModel(l.svcCtx.MysqlConn)
|
||||
func (l *GetQrCodeSetListLogic) GetQrCodeSetList(loginInfo *auth.UserInfo) (resp *types.Response) {
|
||||
qrCodeModel := gmodel.NewFsQrcodeSetModel(l.svcCtx.MysqlConn)
|
||||
qrCodeList, err := qrCodeModel.GetAll(l.ctx)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
@@ -37,7 +38,7 @@ func (l *GetQrCodeSetListLogic) GetQrCodeSetList() (resp *types.Response) {
|
||||
for _, v := range qrCodeList {
|
||||
list = append(list, types.GetQrCodeSetListRsp{
|
||||
Id: v.Id,
|
||||
Name: v.Name,
|
||||
Name: *v.Name,
|
||||
})
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", list)
|
||||
|
||||
@@ -2,9 +2,10 @@ package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fusenapi/model"
|
||||
"fusenapi/model/gmodel"
|
||||
svc2 "fusenapi/server/data-transfer/internal/svc"
|
||||
types2 "fusenapi/server/data-transfer/internal/types"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
@@ -25,8 +26,8 @@ func NewGetStandardLogoListLogic(ctx context.Context, svcCtx *svc2.ServiceContex
|
||||
}
|
||||
|
||||
// 获取标准logo列表
|
||||
func (l *GetStandardLogoListLogic) GetStandardLogoList() (resp *types2.Response) {
|
||||
standardLogoModel := model.NewFsStandardLogoModel(l.svcCtx.MysqlConn)
|
||||
func (l *GetStandardLogoListLogic) GetStandardLogoList(loginInfo *auth.UserInfo) (resp *types2.Response) {
|
||||
standardLogoModel := gmodel.NewFsStandardLogoModel(l.svcCtx.MysqlConn)
|
||||
logoList, err := standardLogoModel.GetAll(l.ctx)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
@@ -36,8 +37,8 @@ func (l *GetStandardLogoListLogic) GetStandardLogoList() (resp *types2.Response)
|
||||
for _, v := range logoList {
|
||||
list = append(list, types2.GetStandardLogoListRsp{
|
||||
Id: v.Id,
|
||||
Name: v.Name,
|
||||
Url: v.Image,
|
||||
Name: *v.Name,
|
||||
Url: *v.Image,
|
||||
})
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", list)
|
||||
|
||||
@@ -2,6 +2,7 @@ package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
"fusenapi/server/data-transfer/internal/svc"
|
||||
@@ -24,7 +25,7 @@ func NewUploadLogoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Upload
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq) (resp *types.Response) {
|
||||
func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, loginInfo *auth.UserInfo) (resp *types.Response) {
|
||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
|
||||
@@ -2,14 +2,13 @@ package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fusenapi/model"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/server/data-transfer/internal/svc"
|
||||
"fusenapi/server/data-transfer/internal/types"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/qrcode"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -28,7 +27,7 @@ func NewUploadQrcodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Uplo
|
||||
}
|
||||
|
||||
// 生成base64二维码
|
||||
func (l *UploadQrcodeLogic) UploadQrcode(req *types.UploadQrcodeReq) (resp *types.Response) {
|
||||
func (l *UploadQrcodeLogic) UploadQrcode(req *types.UploadQrcodeReq, loginInfo *auth.UserInfo) (resp *types.Response) {
|
||||
if req.Url == "" {
|
||||
resp.SetStatus(basic.CodeApiErr, "param url is empty")
|
||||
}
|
||||
@@ -36,23 +35,23 @@ func (l *UploadQrcodeLogic) UploadQrcode(req *types.UploadQrcodeReq) (resp *type
|
||||
resp.SetStatus(basic.CodeApiErr, "param QRcodeType must large than 0")
|
||||
}
|
||||
//获取二维码模板信息
|
||||
qrCodeModel := model.NewFsQrcodeSetModel(l.svcCtx.MysqlConn)
|
||||
qrCodeModel := gmodel.NewFsQrcodeSetModel(l.svcCtx.MysqlConn)
|
||||
qrCodeSet, err := qrCodeModel.FindOne(l.ctx, req.QRcodeType)
|
||||
if err != nil && !errors.Is(err, sqlx.ErrNotFound) {
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get qrcode setting")
|
||||
}
|
||||
if qrCodeSet == nil {
|
||||
if qrCodeSet.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "qrcode setting is not exists")
|
||||
}
|
||||
qrType := qrCodeSet.SvgWebsite.String
|
||||
qrType := *qrCodeSet.SvgWebsite
|
||||
if strings.Contains(req.Url, "www.instagram.com") {
|
||||
qrType = qrCodeSet.SvgInstagram.String
|
||||
qrType = *qrCodeSet.SvgInstagram
|
||||
} else if strings.Contains(req.Url, "www.facebook.com") {
|
||||
qrType = qrCodeSet.SvgFacebook.String
|
||||
qrType = *qrCodeSet.SvgFacebook
|
||||
}
|
||||
//生成二维码
|
||||
imgBase64, err := qrcode.CreateQrCodeBs64WithLogo(req.Url, "", "", 512, int(qrCodeSet.IndexX), int(qrCodeSet.IndexY), true)
|
||||
imgBase64, err := qrcode.CreateQrCodeBs64WithLogo(req.Url, "", "", 512, int(*qrCodeSet.IndexX), int(*qrCodeSet.IndexY), true)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to generate qrcode")
|
||||
|
||||
Reference in New Issue
Block a user