Commit 3d612e2c by 陈健智

批量编辑用户权限调整

parent 73007c4f
......@@ -558,19 +558,21 @@ public class UserServiceImpl implements UserService {
@Override
public ResponseResult updateBatchUserRoles(JSONObject json) {
String id = json.getString("id");
User user = userDao.findOneById(id);
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) {
if (Objects.isNull(role.getExportAmount())) {
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()));
}
oldRoles.addAll(newRoles);
userDao.updateOneByIdWithField(id, new Update().set("roles", oldRoles));
userDao.updateOneByIdWithField(id, new Update().set("roles", newRoles));
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