From b6431d514e86eead7037532abf54e5d92edd907f Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Wed, 30 Aug 2023 16:03:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=8E=A5=E5=8F=A3=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- features/sys_user/api_sys_user.go | 33 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/features/sys_user/api_sys_user.go b/features/sys_user/api_sys_user.go index 400f0a93..0a9c4c61 100644 --- a/features/sys_user/api_sys_user.go +++ b/features/sys_user/api_sys_user.go @@ -29,7 +29,7 @@ func Routers() []services.RouterItem { rs := [...]services.RouterItem{ { Method: "GET", - Pattern: "/userManage/{apiVersion}/list", + Pattern: "/users", Handler: apis.List, Middleware: midware.Authorize(map[string][]string{ "hasPerms": {"system:user:list"}, @@ -37,7 +37,7 @@ func Routers() []services.RouterItem { }, { Method: "GET", - Pattern: "/userManage/{apiVersion}/info/{userId}", + Pattern: "/user/{userId}", Handler: apis.Info, Middleware: midware.Authorize(map[string][]string{ "hasPerms": {"system:user:query"}, @@ -45,7 +45,7 @@ func Routers() []services.RouterItem { }, { Method: "POST", - Pattern: "/userManage/{apiVersion}/add", + Pattern: "/user", Handler: apis.Add, Middleware: midware.Authorize(map[string][]string{ "hasPerms": {"system:user:add"}, @@ -53,7 +53,7 @@ func Routers() []services.RouterItem { }, { Method: "PUT", - Pattern: "/userManage/{apiVersion}/edit", + Pattern: "/user", Handler: apis.Edit, Middleware: midware.Authorize(map[string][]string{ "hasPerms": {"system:user:edit"}, @@ -61,7 +61,7 @@ func Routers() []services.RouterItem { }, { Method: "DELETE", - Pattern: "/userManage/{apiVersion}/del/{userIds}", + Pattern: "/user/{userIds}", Handler: apis.Remove, Middleware: midware.Authorize(map[string][]string{ "hasPerms": {"system:user:edit"}, @@ -73,7 +73,7 @@ func Routers() []services.RouterItem { // 生成两组前缀路由 rsPrefix := []services.RouterItem{} for _, v := range rs { - path := v.Pattern + path := "/userManage/{apiVersion}" + v.Pattern // 固定前缀 v.Pattern = config.DefaultUriPrefix + path rsPrefix = append(rsPrefix, v) @@ -139,7 +139,6 @@ func (s *SysUserApi) Info(w http.ResponseWriter, r *http.Request) { ctx.JSON(w, 200, result.OkData(map[string]any{ "user": map[string]any{}, "roleIds": []string{}, - "postIds": []string{}, "roles": roles, })) return @@ -177,9 +176,9 @@ func (s *SysUserApi) Add(w http.ResponseWriter, r *http.Request) { } // 检查用户登录账号是否唯一 - uniqueUserName := s.sysUserService.CheckUniqueUserName(body.Name, "") + uniqueUserName := s.sysUserService.CheckUniqueUserName(body.AccountId, "") if !uniqueUserName { - msg := fmt.Sprintf("新增用户【%s】失败,登录账号已存在", body.Name) + msg := fmt.Sprintf("新增用户【%s】失败,登录账号已存在", body.AccountId) ctx.JSON(w, 200, result.ErrMsg(msg)) return } @@ -204,10 +203,10 @@ func (s *SysUserApi) Edit(w http.ResponseWriter, r *http.Request) { } // 检查是否管理员用户 - if conf.IsAdmin(body.Id) { - ctx.JSON(w, 200, result.ErrMsg("不允许操作管理员用户")) - return - } + // if conf.IsAdmin(body.Id) { + // ctx.JSON(w, 200, result.ErrMsg("不允许操作管理员用户")) + // return + // } user := s.sysUserService.SelectUserById(body.Id) if user.Id != body.Id { @@ -216,15 +215,15 @@ func (s *SysUserApi) Edit(w http.ResponseWriter, r *http.Request) { } // 检查用户登录账号是否唯一 - uniqueUserName := s.sysUserService.CheckUniqueUserName(body.Name, body.Id) + uniqueUserName := s.sysUserService.CheckUniqueUserName(body.AccountId, body.Id) if !uniqueUserName { - msg := fmt.Sprintf("修改用户【%s】失败,登录账号已存在", body.Name) + msg := fmt.Sprintf("修改用户【%s】失败,登录账号已存在", body.AccountId) ctx.JSON(w, 200, result.ErrMsg(msg)) return } - body.Name = "" // 忽略修改登录用户名称 - body.Password = "" // 忽略修改密码 + body.AccountId = "" // 忽略修改登录用户名称 + // body.Password = "" // 忽略修改密码 rows := s.sysUserService.UpdateUserAndRolePost(body) if rows > 0 { ctx.JSON(w, 200, result.Ok(nil))