Commit 3d612e2c by 陈健智

批量编辑用户权限调整

parent 73007c4f
...@@ -558,19 +558,21 @@ public class UserServiceImpl implements UserService { ...@@ -558,19 +558,21 @@ public class UserServiceImpl implements UserService {
@Override @Override
public ResponseResult updateBatchUserRoles(JSONObject json) { public ResponseResult updateBatchUserRoles(JSONObject json) {
String id = json.getString("id"); String id = json.getString("id");
User user = userDao.findOneById(id);
List<UserRole> newRoles = json.getJSONArray("roles").toJavaList(UserRole.class); List<UserRole> newRoles = json.getJSONArray("roles").toJavaList(UserRole.class);
List<String> keys = newRoles.stream().map(UserRole::getKey).collect(Collectors.toList());
// 无需被修改的权限列表
List<UserRole> oldRoles = user.getRoles().stream().filter(role -> !keys.contains(role.getKey())).collect(Collectors.toList());
for (UserRole role : newRoles) { for (UserRole role : newRoles) {
if (Objects.isNull(role.getExportAmount())) { if (Objects.isNull(role.getExportAmount())) {
role.setExportAmount(1000); role.setExportAmount(1000);
} }
if (Objects.isNull(role.getExpiredTime()) && RoleEnum.CUSTOMER.getState() == role.getRoleId()){
role.setExpiredTime(System.currentTimeMillis() + Constant.ONE_WEEK);
}
if (Objects.isNull(role.getSearchWholeRights()) && Objects.isNull(role.getSearchWholeRange())) {
role.setSearchWholeRange(1);
role.setSearchWholeRights(1);
}
role.setKey(Tools.concat(role.getProjectId(), role.getRoleId())); role.setKey(Tools.concat(role.getProjectId(), role.getRoleId()));
} }
oldRoles.addAll(newRoles); userDao.updateOneByIdWithField(id, new Update().set("roles", newRoles));
userDao.updateOneByIdWithField(id, new Update().set("roles", oldRoles));
return ResponseResult.success(); return ResponseResult.success();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment