From fe9b132fb49182db30b1155c1d76d4b02ddf2324 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 16 十一月 2022 15:22:42 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/controller/sys/UserController.java | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/lf/server/controller/sys/UserController.java b/src/main/java/com/lf/server/controller/sys/UserController.java index 1c28601..0f532ce 100644 --- a/src/main/java/com/lf/server/controller/sys/UserController.java +++ b/src/main/java/com/lf/server/controller/sys/UserController.java @@ -1,10 +1,11 @@ package com.lf.server.controller.sys; -import com.lf.server.aspect.SysLog; +import com.lf.server.annotation.SysLog; import com.lf.server.controller.all.BaseController; import com.lf.server.entity.all.ResponseMsg; import com.lf.server.entity.sys.UserEntity; import com.lf.server.entity.ctrl.UserUpdateEntity; +import com.lf.server.helper.StringHelper; import com.lf.server.service.sys.TokenService; import com.lf.server.service.sys.UserService; import io.swagger.annotations.Api; @@ -140,6 +141,26 @@ } @SysLog() + @ApiOperation(value = "鏍规嵁鐢ㄦ埛ID鏌ヨ") + @ApiImplicitParams({ + @ApiImplicitParam(name = "uid", value = "鐢ㄦ埛ID", dataType = "String", paramType = "query", example = "admin") + }) + @GetMapping(value = "/selectByUid") + public ResponseMsg<UserEntity> selectByUid(String uid) { + try { + if (StringHelper.isEmpty(uid)) { + fail("鐢ㄦ埛ID涓嶈兘涓虹┖", null); + } + + UserEntity userEntity = userService.selectByUid(uid); + + return success(userEntity); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } + } + + @SysLog() @ApiOperation(value = "鏌ヨ鎵�鏈�") @GetMapping(value = "/selectUserAll") public ResponseMsg<List<UserEntity>> selectUserAll() { @@ -149,6 +170,24 @@ return success(list); } catch (Exception ex) { return fail(ex.getMessage(), null); + } + } + + @SysLog() + @ApiOperation(value = "鏌ヨ鏄�/鍚︿负绠$悊鍛�") + @GetMapping(value = "/selectForIsAdmin") + public ResponseMsg<Boolean> selectForIsAdmin(HttpServletRequest req) { + try { + UserEntity ue = tokenService.getCurrentUser(req); + if (ue == null) { + return fail("鐢ㄦ埛鏈櫥褰�", false); + } + + Integer rows = userService.selectForIsAdmin(ue.getId()); + + return success("鎴愬姛", rows > 0); + } catch (Exception ex) { + return fail(ex.getMessage(), false); } } @@ -196,7 +235,6 @@ if (str != null) { return fail(str, -1); } - if (ue != null) { entity.setCreateUser(ue.getId()); } @@ -293,12 +331,17 @@ return fail(str, false); } + Integer rows = userService.selectForIsAdmin(ue.getId()); + if (rows < 1) { + return fail("鍙厑璁哥鐞嗗憳鎿嶄綔", false); + } + str = userService.validateNewPwd(ue, uue.getNewPwd()); if (str != null) { return fail(str, false); } - Integer rows = userService.updateUsersPwd(ue.getId(), ue.getSalt(), uue.getIds()); + rows = userService.updateUsersPwd(ue.getId(), ue.getSalt(), uue.getIds()); return success(rows > 0 ? "鏇存柊鎴愬姛" : "鏇存柊澶辫触", rows > 0); } catch (Exception ex) { -- Gitblit v1.9.3