From 7b6048096661d8cbcdb17f0ecfda667ae5716d69 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期二, 10 九月 2024 10:49:15 +0800 Subject: [PATCH] # --- zy-acs-manager/src/main/java/com/zy/acs/manager/system/controller/UserController.java | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-) diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/system/controller/UserController.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/system/controller/UserController.java index 64fa4b2..dc86572 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/system/controller/UserController.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/system/controller/UserController.java @@ -83,7 +83,9 @@ return R.error("the phone already exist"); } - user.setPassword(userService.encodePassword(COMMON_PASSWORD)); + if (Cools.isEmpty(user.getPassword())) { + user.setPassword(userService.encodePassword(COMMON_PASSWORD)); + } user.setCreateBy(getLoginUserId()); user.setCreateTime(new Date()); @@ -95,13 +97,15 @@ } userRoleService.remove(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, user.getId())); - for (Long roleId : user.getRoleIds()) { - if (!userRoleService.save(new UserRole(user.getId(), roleId))) { - throw new CoolException("Internal Server Error"); + if (!Cools.isEmpty((Object) user.getRoleIds())) { + for (Long roleId : user.getRoleIds()) { + if (!userRoleService.save(new UserRole(user.getId(), roleId))) { + throw new CoolException("Internal Server Error"); + } } } - return R.ok("Save Success"); + return R.ok("Save Success").add(user); } @PreAuthorize("hasAuthority('system:user:update')") @@ -145,7 +149,7 @@ } } - return R.ok("Update Success"); + return R.ok("Update Success").add(user); } @PreAuthorize("hasAuthority('system:user:remove')") @@ -157,11 +161,9 @@ if (!userService.removeById(userId)) { throw new CoolException("Internal Server Error"); } - if (!userRoleService.remove(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, userId))) { - throw new CoolException("Internal Server Error"); - } + userRoleService.remove(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, userId)); } - return R.ok("Delete Success"); + return R.ok("Delete Success").add(ids); } @PreAuthorize("hasAuthority('system:user:list')") -- Gitblit v1.9.1