Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
||||
"fusenapi/server/data-transfer/internal/logic"
|
||||
"fusenapi/server/data-transfer/internal/svc"
|
||||
)
|
||||
|
||||
// 获取二维码配置列表
|
||||
func GetQrCodeSetListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := logic.NewGetQrCodeSetListLogic(r.Context(), svcCtx)
|
||||
resp := l.GetQrCodeSetList()
|
||||
if resp != nil {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
} else {
|
||||
err := errors.New("server logic is error, resp must not be nil")
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
logx.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,14 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
svc2 "fusenapi/server/data-transfer/internal/svc"
|
||||
"net/http"
|
||||
|
||||
"fusenapi/server/data-transfer/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
func RegisterHandlers(server *rest.Server, serverCtx *svc2.ServiceContext) {
|
||||
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
@@ -16,6 +17,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc2.ServiceContext) {
|
||||
Path: "/standard-logo/list",
|
||||
Handler: GetStandardLogoListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/qrcode-set/list",
|
||||
Handler: GetQrCodeSetListHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||
)
|
||||
|
||||
44
server/data-transfer/internal/logic/getqrcodesetlistlogic.go
Normal file
44
server/data-transfer/internal/logic/getqrcodesetlistlogic.go
Normal file
@@ -0,0 +1,44 @@
|
||||
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)
|
||||
}
|
||||
@@ -11,6 +11,11 @@ type GetStandardLogoListRsp struct {
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type GetQrCodeSetListRsp struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"msg"`
|
||||
|
||||
Reference in New Issue
Block a user