This commit is contained in:
laodaming
2023-06-20 14:59:13 +08:00
parent 8a4e122a0a
commit 0f4ae5164b
5 changed files with 114 additions and 123 deletions

View File

@@ -12,7 +12,6 @@ import (
"fusenapi/server/map-library/internal/logic"
"fusenapi/server/map-library/internal/svc"
"fusenapi/server/map-library/internal/types"
)
func SaveMapLibraryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
@@ -52,20 +51,9 @@ func SaveMapLibraryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
// 如果claims为nil,则认为用户身份为白板用户
userinfo = &auth.UserInfo{UserId: 0, GuestId: 0}
}
var req types.SaveMapLibraryReq
// 如果端点有请求结构体则使用httpx.Parse方法从HTTP请求体中解析请求数据
if err := httpx.Parse(r, &req); err != nil {
httpx.OkJsonCtx(r.Context(), w, &basic.Response{
Code: 510,
Message: "parameter error",
})
logx.Info(err)
return
}
// 创建一个业务逻辑层实例
l := logic.NewSaveMapLibraryLogic(r.Context(), svcCtx)
resp := l.SaveMapLibrary(&req, userinfo)
resp := l.SaveMapLibrary(userinfo, r)
// 如果响应不为nil则使用httpx.OkJsonCtx方法返回JSON响应;
if resp != nil {
httpx.OkJsonCtx(r.Context(), w, resp)