Commit 3a6aca85e4c4518ce7c59527f21973dfc0f491fe

Authored by chenjunyu_1481036421
1 parent b43050bc

fix:1.去掉组织不能为空提示 2.普通租户菜单权限问题 3.用户账号时效为null不修改问题 4.前端菜单权限

feat:1.重置密码需求
@@ -63,7 +63,7 @@ public class TkRoleController extends BaseController { @@ -63,7 +63,7 @@ public class TkRoleController extends BaseController {
63 63
64 @DeleteMapping 64 @DeleteMapping
65 @PreAuthorize( 65 @PreAuthorize(
66 - "@check.checkPermissions({'SYS_ADMIN','PLATFORM_ADMIN','TENANT_ADMIN'},{'api:yt:role:delete'})") 66 + "@check.checkPermissions({'SYS_ADMIN','PLATFORM_ADMIN','TENANT_ADMIN'},{'api:yt:tenant:role:delete','api:yt:custom:role:delete'})")
67 public void deleteRole(@RequestBody String[] ids) throws ThingsboardException { 67 public void deleteRole(@RequestBody String[] ids) throws ThingsboardException {
68 roleService.deleteRole(ids, getCurrentUser().getCurrentTenantId()); 68 roleService.deleteRole(ids, getCurrentUser().getCurrentTenantId());
69 } 69 }
@@ -73,6 +73,7 @@ public class TkRoleController extends BaseController { @@ -73,6 +73,7 @@ public class TkRoleController extends BaseController {
73 return roleService.getPermissions( 73 return roleService.getPermissions(
74 getCurrentUser().isPtSysadmin(), 74 getCurrentUser().isPtSysadmin(),
75 getCurrentUser().isPtTenantAdmin(), 75 getCurrentUser().isPtTenantAdmin(),
  76 + getCurrentUser().isPtCommonTenant(),
76 getCurrentUser().getCurrentTenantId(), 77 getCurrentUser().getCurrentTenantId(),
77 getCurrentUser().getCurrentUserId()); 78 getCurrentUser().getCurrentUserId());
78 } 79 }
@@ -88,7 +89,7 @@ public class TkRoleController extends BaseController { @@ -88,7 +89,7 @@ public class TkRoleController extends BaseController {
88 89
89 @PostMapping("save_with_menu") 90 @PostMapping("save_with_menu")
90 @PreAuthorize( 91 @PreAuthorize(
91 - "@check.checkPermissions({'SYS_ADMIN','PLATFORM_ADMIN','TENANT_ADMIN'},{'api:yt:role:saveOrUpdateRoleInfoWithMenu:post','api:yt:role:saveOrUpdateRoleInfoWithMenu:update'})") 92 + "@check.checkPermissions({'SYS_ADMIN','PLATFORM_ADMIN','TENANT_ADMIN'},{'api:yt:tenant:role:post','api:yt:tenant:role:update'})")
92 public RoleDTO saveOrUpdateRoleInfoWithMenu(@RequestBody RoleReqDTO roleReqDTO) 93 public RoleDTO saveOrUpdateRoleInfoWithMenu(@RequestBody RoleReqDTO roleReqDTO)
93 throws ThingsboardException { 94 throws ThingsboardException {
94 if (getCurrentUser().isPtAdmin() && null == roleReqDTO.getRoleType()) { 95 if (getCurrentUser().isPtAdmin() && null == roleReqDTO.getRoleType()) {
@@ -361,14 +361,13 @@ public class TkUserController extends AbstractUserAccount { @@ -361,14 +361,13 @@ public class TkUserController extends AbstractUserAccount {
361 orgIds)); 361 orgIds));
362 } 362 }
363 363
364 - @PostMapping("/reset_password/{userId}") 364 + @PostMapping("/reset_password/{userId}/{level}")
365 @ApiOperation(value = "重置客户密码") 365 @ApiOperation(value = "重置客户密码")
366 @PreAuthorize( 366 @PreAuthorize(
367 "@check.checkPermissions({'SYS_ADMIN','TENANT_ADMIN'},{'api:yt:user:resetPassword'})") 367 "@check.checkPermissions({'SYS_ADMIN','TENANT_ADMIN'},{'api:yt:user:resetPassword'})")
368 - public ResponseResult resetPassword(@PathVariable("userId") String userId) 368 + public ResponseResult resetPassword(@PathVariable("userId") String userId,@PathVariable("level") Integer level)
369 throws ThingsboardException { 369 throws ThingsboardException {
370 boolean isSysAdmin = getCurrentUser().isSystemAdmin(); 370 boolean isSysAdmin = getCurrentUser().isSystemAdmin();
371 - Integer level = isSysAdmin ? 1 : 3;  
372 // 检查平台、客户账号 371 // 检查平台、客户账号
373 UserDTO user = userService.checkAccount(userId, level); 372 UserDTO user = userService.checkAccount(userId, level);
374 if (null == user) { 373 if (null == user) {
@@ -47,7 +47,8 @@ public class PermissionTools { @@ -47,7 +47,8 @@ public class PermissionTools {
47 } 47 }
48 48
49 if (needPermission != null && !needPermission.isEmpty()) { 49 if (needPermission != null && !needPermission.isEmpty()) {
50 - Set<String> userPermissions = roleService.getPermissions(securityUser.isPtSysadmin(), securityUser.isPtTenantAdmin(), securityUser.getCurrentTenantId(), securityUser.getCurrentUserId()); 50 + Set<String> userPermissions = roleService.getPermissions(securityUser.isPtSysadmin(), securityUser.isPtTenantAdmin(),
  51 + securityUser.isPtCommonTenant(), securityUser.getCurrentTenantId(), securityUser.getCurrentUserId());
51 if (userPermissions == null || userPermissions.isEmpty()) { 52 if (userPermissions == null || userPermissions.isEmpty()) {
52 return false; 53 return false;
53 } 54 }
@@ -37,8 +37,6 @@ public class ConvertConfigDTO extends TenantDTO { @@ -37,8 +37,6 @@ public class ConvertConfigDTO extends TenantDTO {
37 @ApiModelProperty(value = "数据源内容") 37 @ApiModelProperty(value = "数据源内容")
38 private JsonNode datasourceContent; 38 private JsonNode datasourceContent;
39 39
40 - @ApiModelProperty(value = "组织id")  
41 - @NotEmpty(message = "组织不能为空或者空字符串")  
42 private String organizationId; 40 private String organizationId;
43 41
44 private transient Integer nodeType; 42 private transient Integer nodeType;
@@ -33,6 +33,7 @@ public class SysUserEntity extends TenantBaseEntity { @@ -33,6 +33,7 @@ public class SysUserEntity extends TenantBaseEntity {
33 33
34 private boolean enabled = true; 34 private boolean enabled = true;
35 35
  36 + @TableField(updateStrategy = FieldStrategy.IGNORED)
36 private LocalDateTime accountExpireTime; 37 private LocalDateTime accountExpireTime;
37 38
38 private String deptId; 39 private String deptId;
@@ -99,7 +99,7 @@ public class SysRoleServiceImpl extends AbstractBaseService<RoleMapper, SysRoleE @@ -99,7 +99,7 @@ public class SysRoleServiceImpl extends AbstractBaseService<RoleMapper, SysRoleE
99 99
100 @Override 100 @Override
101 public Set<String> getPermissions( 101 public Set<String> getPermissions(
102 - boolean isSysadmin, boolean isTenantAdmin, String tenantId, String useerId) { 102 + boolean isSysadmin, boolean isTenantAdmin,boolean isCommonTenant, String tenantId, String useerId) {
103 Set<String> permissions = Sets.newHashSet(); 103 Set<String> permissions = Sets.newHashSet();
104 Set<String> allPermission; 104 Set<String> allPermission;
105 String cacheKey; 105 String cacheKey;
@@ -110,7 +110,7 @@ public class SysRoleServiceImpl extends AbstractBaseService<RoleMapper, SysRoleE @@ -110,7 +110,7 @@ public class SysRoleServiceImpl extends AbstractBaseService<RoleMapper, SysRoleE
110 cacheUtils.get(FastIotConstants.CacheConfigKey.CACHE_CONFIG_KEY, cacheKey); 110 cacheUtils.get(FastIotConstants.CacheConfigKey.CACHE_CONFIG_KEY, cacheKey);
111 cachePresent = optionalPermission.isPresent(); 111 cachePresent = optionalPermission.isPresent();
112 allPermission = optionalPermission.orElseGet(menuMapper::getAllPermission); 112 allPermission = optionalPermission.orElseGet(menuMapper::getAllPermission);
113 - } else if (isTenantAdmin) { 113 + }else if (isTenantAdmin&&!isCommonTenant) {
114 cacheKey = FastIotConstants.CacheConfigKey.USER_PERMISSION_PREFIX + tenantId; 114 cacheKey = FastIotConstants.CacheConfigKey.USER_PERMISSION_PREFIX + tenantId;
115 Optional<Set<String>> optionalPermission = 115 Optional<Set<String>> optionalPermission =
116 cacheUtils.get(FastIotConstants.CacheConfigKey.CACHE_CONFIG_KEY, cacheKey); 116 cacheUtils.get(FastIotConstants.CacheConfigKey.CACHE_CONFIG_KEY, cacheKey);
@@ -126,7 +126,7 @@ public class SysRoleServiceImpl extends AbstractBaseService<RoleMapper, SysRoleE @@ -126,7 +126,7 @@ public class SysRoleServiceImpl extends AbstractBaseService<RoleMapper, SysRoleE
126 optionalPermission.orElseGet(() -> menuMapper.getAllPermissionsByUserId(useerId)); 126 optionalPermission.orElseGet(() -> menuMapper.getAllPermissionsByUserId(useerId));
127 } 127 }
128 if (cachePresent) { 128 if (cachePresent) {
129 - return allPermission; 129 + return allPermission;
130 } else { 130 } else {
131 allPermission.forEach( 131 allPermission.forEach(
132 permission -> permissions.addAll(Sets.newHashSet(permission.split(",")))); 132 permission -> permissions.addAll(Sets.newHashSet(permission.split(","))));
@@ -14,7 +14,7 @@ public interface RoleService { @@ -14,7 +14,7 @@ public interface RoleService {
14 14
15 boolean deleteRole(String[] roleIds,String tenantId); 15 boolean deleteRole(String[] roleIds,String tenantId);
16 16
17 - Set<String> getPermissions(boolean isSysadmin,boolean isTenantAdmin,String tenantId,String useerId); 17 + Set<String> getPermissions(boolean isSysadmin,boolean isTenantAdmin,boolean isCommonTenant,String tenantId,String useerId);
18 18
19 void updateRoleStatus(String roleId, int status,boolean isSysadmin,String tenantId); 19 void updateRoleStatus(String roleId, int status,boolean isSysadmin,String tenantId);
20 20