From f7da17778edacadea1ef7c4c8880a963aebd0b83 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 14 Jun 2023 16:04:43 +0800 Subject: [PATCH] fix --- model/gmodel/fsmaplibrarymodel.go | 2 +- .../internal/handler/getmaplibrarylisthandler.go | 10 ++++++---- .../internal/logic/getmaplibrarylistlogic.go | 2 +- server/map_library/internal/types/types.go | 4 ++-- server_api/map_library.api | 4 ++-- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/model/gmodel/fsmaplibrarymodel.go b/model/gmodel/fsmaplibrarymodel.go index 1084e333..58c02db6 100755 --- a/model/gmodel/fsmaplibrarymodel.go +++ b/model/gmodel/fsmaplibrarymodel.go @@ -23,7 +23,7 @@ func NewFsMapLibraryModel(db *gorm.DB) *FsMapLibraryModel { } func (ml *FsMapLibraryModel) GetAllEnabledList(ctx context.Context) (resp []FsMapLibrary, err error) { - err = ml.db.WithContext(ctx).Model(&FsMapLibrary{}).Where("`status` = ?", 1).Find(&resp).Error + err = ml.db.WithContext(ctx).Model(&FsMapLibrary{}).Where("`status` = ?", 0).Find(&resp).Error if err != nil { return nil, err } diff --git a/server/map_library/internal/handler/getmaplibrarylisthandler.go b/server/map_library/internal/handler/getmaplibrarylisthandler.go index bad5e65d..f81221e0 100644 --- a/server/map_library/internal/handler/getmaplibrarylisthandler.go +++ b/server/map_library/internal/handler/getmaplibrarylisthandler.go @@ -7,14 +7,16 @@ import ( "github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/rest/httpx" + "fusenapi/utils/auth" + "fusenapi/utils/basic" + "fusenapi/server/map_library/internal/logic" "fusenapi/server/map_library/internal/svc" - "fusenapi/utils/auth" ) func GetMapLibraryListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - /*// 解析jwtToken + // 解析jwtToken claims, err := svcCtx.ParseJwtToken(r) // 如果解析出错,则返回未授权的JSON响应并记录错误消息 if err != nil { @@ -36,10 +38,10 @@ func GetMapLibraryListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { }) logx.Info("unauthorized:", err.Error()) return - }*/ + } l := logic.NewGetMapLibraryListLogic(r.Context(), svcCtx) - resp := l.GetMapLibraryList(&auth.UserInfo{86}) + resp := l.GetMapLibraryList(userinfo) // 如果响应不为nil,则使用httpx.OkJsonCtx方法返回JSON响应; // 否则,发送500内部服务器错误的JSON响应并记录错误消息logx.Error。 if resp != nil { diff --git a/server/map_library/internal/logic/getmaplibrarylistlogic.go b/server/map_library/internal/logic/getmaplibrarylistlogic.go index fc393b47..0cae21dc 100644 --- a/server/map_library/internal/logic/getmaplibrarylistlogic.go +++ b/server/map_library/internal/logic/getmaplibrarylistlogic.go @@ -75,5 +75,5 @@ func (l *GetMapLibraryListLogic) GetMapLibraryList(userinfo *auth.UserInfo) (res data.Info = info list = append(list, data) } - return resp.SetStatus(basic.CodeOK) + return resp.SetStatusWithMessage(basic.CodeOK, "success", list) } diff --git a/server/map_library/internal/types/types.go b/server/map_library/internal/types/types.go index 31ebf05e..75af6051 100644 --- a/server/map_library/internal/types/types.go +++ b/server/map_library/internal/types/types.go @@ -29,12 +29,12 @@ type MapLibraryListInfo struct { Align string `json:"align"` VerticalAlign string `json:"verticalAlign"` Material string `json:"material"` - QRcodeType string `json:"QRcodeType"` + QRcodeType int64 `json:"QRcodeType"` Width float64 `json:"width"` Height float64 `json:"height"` X float64 `json:"x"` Y float64 `json:"y"` - Opacity int64 `json:"opacity"` + Opacity float64 `json:"opacity"` OptionalColor []MapLibraryListOptionalColorItem `json:"optionalColor"` ZIndex int64 `json:"zIndex"` SvgPath string `json:"svgPath"` diff --git a/server_api/map_library.api b/server_api/map_library.api index d752b57c..db3a3436 100644 --- a/server_api/map_library.api +++ b/server_api/map_library.api @@ -38,12 +38,12 @@ type MapLibraryListInfo { Align string `json:"align"` VerticalAlign string `json:"verticalAlign"` Material string `json:"material"` - QRcodeType string `json:"QRcodeType"` + QRcodeType int64 `json:"QRcodeType"` Width float64 `json:"width"` Height float64 `json:"height"` X float64 `json:"x"` Y float64 `json:"y"` - Opacity int64 `json:"opacity"` + Opacity float64 `json:"opacity"` OptionalColor []MapLibraryListOptionalColorItem `json:"optionalColor"` ZIndex int64 `json:"zIndex"` SvgPath string `json:"svgPath"`