From 9776a87bb29d147da919cedb3e4f897263f2b499 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 10 九月 2024 13:11:09 +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