From fc0ad32f815535a5a4aee55f92eaac92cbd4d97b Mon Sep 17 00:00:00 2001 From: jiang <893224616@qq.com> Date: Tue, 19 Jul 2022 18:13:19 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E6=96=B0=E5=A2=9E=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=B2=A1=E6=9C=89pushkey=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=202.=E5=B0=86=E9=87=8D=E7=BD=AEpushkey=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E4=BF=AE=E6=94=B9pushkey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/service/IUserService.java | 2 +- .../iot/vmp/service/impl/UserServiceImpl.java | 4 +- .../iot/vmp/storager/dao/UserMapper.java | 4 +- .../iot/vmp/vmanager/user/UserController.java | 15 +-- web_src/src/components/UserManager.vue | 52 ++++----- .../src/components/dialog/changePushKey.vue | 102 ++++++++++++++++++ 6 files changed, 142 insertions(+), 37 deletions(-) create mode 100644 web_src/src/components/dialog/changePushKey.vue diff --git a/src/main/java/com/genersoft/iot/vmp/service/IUserService.java b/src/main/java/com/genersoft/iot/vmp/service/IUserService.java index 616fd1a3..7e2a8395 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IUserService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IUserService.java @@ -25,5 +25,5 @@ public interface IUserService { PageInfo getUsers(int page, int count); - int resetPushKey(int id); + int changePushKey(int id, String pushKey); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java index 46d9ad5d..f5dc7b0f 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java @@ -75,7 +75,7 @@ public class UserServiceImpl implements IUserService { } @Override - public int resetPushKey(int id) { - return userMapper.resetPushKey(id); + public int changePushKey(int id, String pushKey) { + return userMapper.changePushKey(id,pushKey); } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java index 57d2fdc3..c7a44fd2 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java @@ -60,6 +60,6 @@ public interface UserMapper { @ResultMap(value="roleMap") List getUsers(); - @Delete("update user set pushKey=MD5(NOW()+#{id}) where id=#{id}") - int resetPushKey(int id); + @Update("update user set pushKey=#{pushKey} where id=#{id}") + int changePushKey(int id, String pushKey); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java index ca6fc84e..442832bf 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java @@ -124,7 +124,8 @@ public class UserController { User user = new User(); user.setUsername(username); user.setPassword(DigestUtils.md5DigestAsHex(password.getBytes())); - + //新增用户的pushKey的生成规则为md5(时间戳+用户名) + user.setPushKey(DigestUtils.md5DigestAsHex((System.currentTimeMillis()+password).getBytes())); Role role = roleService.getRoleById(roleId); if (role == null) { @@ -138,6 +139,7 @@ public class UserController { user.setUpdateTime(DateUtil.getNow()); int addResult = userService.addUser(user); + result.setCode(addResult > 0 ? 0 : -1); result.setMsg(addResult > 0 ? "success" : "fail"); result.setData(addResult); @@ -196,12 +198,13 @@ public class UserController { return userService.getUsers(page, count); } - @ApiOperation("重置pushkey") + @ApiOperation("修改pushkey") @ApiImplicitParams({ - @ApiImplicitParam(name = "id", required = true, value = "用户Id", dataTypeClass = Integer.class), + @ApiImplicitParam(name = "userId", required = true, value = "用户Id", dataTypeClass = Integer.class), + @ApiImplicitParam(name = "pushKey", required = true, value = "新的pushKey", dataTypeClass = String.class), }) - @RequestMapping("/resetPushKey") - public ResponseEntity> resetPushKey(@RequestParam Integer id) { + @RequestMapping("/changePushKey") + public ResponseEntity> changePushKey(@RequestParam Integer userId,@RequestParam String pushKey) { // 获取当前登录用户id int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); WVPResult result = new WVPResult<>(); @@ -211,7 +214,7 @@ public class UserController { result.setMsg("用户无权限"); return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); } - int resetPushKeyResult = userService.resetPushKey(id); + int resetPushKeyResult = userService.changePushKey(userId,pushKey); result.setCode(resetPushKeyResult > 0 ? 0 : -1); result.setMsg(resetPushKeyResult > 0 ? "success" : "fail"); diff --git a/web_src/src/components/UserManager.vue b/web_src/src/components/UserManager.vue index 10faf6d3..1048f539 100644 --- a/web_src/src/components/UserManager.vue +++ b/web_src/src/components/UserManager.vue @@ -21,7 +21,7 @@