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 | 37 ++++++++++++++++++-------------------
1 files changed, 18 insertions(+), 19 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 8a11520..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
@@ -6,6 +6,7 @@
import com.zy.acs.manager.common.domain.BaseParam;
import com.zy.acs.manager.common.domain.KeyValVo;
import com.zy.acs.manager.common.domain.PageParam;
+import com.zy.acs.manager.common.domain.PageResult;
import com.zy.acs.manager.common.utils.ExcelUtil;
import com.zy.acs.manager.system.controller.param.ResetPwdParam;
import com.zy.acs.manager.system.entity.User;
@@ -39,15 +40,11 @@
public R page(@RequestBody Map<String, Object> map) {
BaseParam baseParam = buildParam(map, BaseParam.class);
PageParam<User, BaseParam> pageParam = new PageParam<>(baseParam, User.class);
- return R.ok().add(userService.page(pageParam, pageParam.buildWrapper(true, wrapper -> wrapper.orderByAsc("create_time"))));
- }
-
- @PreAuthorize("hasAuthority('system:user:list')")
- @PostMapping("/user/page1")
- public R page1(@RequestBody Map<String, Object> map) {
- BaseParam baseParam = buildParam(map, BaseParam.class);
- PageParam<User, BaseParam> pageParam = new PageParam<>(baseParam, User.class);
- return R.ok().add(userService.pageRel(pageParam));
+ PageResult<User> pageResult = userService.pageRel(pageParam);
+ for (User record : pageResult.getRecords()) {
+ record.setRoles(userRoleService.listByUserId(record.getId()));
+ }
+ return R.ok().add(pageResult);
}
@PreAuthorize("hasAuthority('system:user:list')")
@@ -86,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());
@@ -98,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')")
@@ -148,7 +149,7 @@
}
}
- return R.ok("Update Success");
+ return R.ok("Update Success").add(user);
}
@PreAuthorize("hasAuthority('system:user:remove')")
@@ -160,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