Commit 83832ddaf273fc468f9def12ee404da4875b9578

Authored by 芯火源
1 parent d42f4be4

refactor: 租户管理员权限有租户级调整为用户级

... ... @@ -10,6 +10,7 @@ import org.thingsboard.server.common.data.yunteng.enums.UserStatusEnum;
10 10
11 11 import javax.validation.constraints.NotEmpty;
12 12 import java.time.LocalDateTime;
  13 +import java.util.List;
13 14 import java.util.Set;
14 15
15 16 @EqualsAndHashCode(callSuper = false)
... ... @@ -38,7 +39,7 @@ public class UserDTO extends BaseDTO {
38 39 private String[] organizationIds;
39 40
40 41 @ApiModelProperty(value = "角色ids")
41   - private String[] roleIds;
  42 + private List<String> roleIds;
42 43
43 44 @ApiModelProperty(value = "电话号码")
44 45 @NotEmpty(message = "电话号码不能为空或字符串", groups = AddGroup.class)
... ...
... ... @@ -130,7 +130,7 @@ public class SysUserServiceImpl extends AbstractBaseService<UserMapper, SysUserE
130 130 SysUserRoleEntity userRole = new SysUserRoleEntity();
131 131 userRole.setUserId(user.getId());
132 132 userRole.setRoleId(roleId);
133   - userRoleMapper.insert(userRole);
  133 +// userRoleMapper.insert(userRole);
134 134 }
135 135 // 绑定用户和组织的关系
136 136 organizationService.bindUserToOrganization(
... ... @@ -311,7 +311,7 @@ public class SysUserServiceImpl extends AbstractBaseService<UserMapper, SysUserE
311 311 }
312 312 baseMapper.updateById(user);
313 313 if (null != userDTO.getRoleIds()) {
314   - deleteAndAddUserRole(user.getId(), Arrays.asList(userDTO.getRoleIds()));
  314 + deleteAndAddUserRole(user.getId(), userDTO.getRoleIds());
315 315 userOrganizationMappingService.addOrUpdateUserOrganizationMapping(
316 316 user.getId(), Arrays.asList(userDTO.getOrganizationIds()), true);
317 317 }
... ... @@ -450,7 +450,10 @@ public class SysUserServiceImpl extends AbstractBaseService<UserMapper, SysUserE
450 450 baseMapper.insert(user);
451 451 List<SysTenantRoleEntity> tenantRoleList = validateTenantRole(userDTO.getTenantId());
452 452 for (SysTenantRoleEntity tenantRole : tenantRoleList) {
453   - roleMapper.saveUserRoleMapping(user.getId(), tenantRole.getRoleId());
  453 + String roleId = tenantRole.getRoleId();
  454 + if(userDTO.getRoleIds().contains(roleId)){
  455 + roleMapper.saveUserRoleMapping(user.getId(), roleId);
  456 + }
454 457 }
455 458 user.copyToDTO(userDTO, PASSWORD, ACTIVATE_TOKEN);
456 459 return userDTO;
... ...