|
|
@ -128,11 +128,12 @@ public class RoleOperationServiceImpl extends BaseServiceImpl<RoleOperationDao, |
|
|
|
for (InitDefaultOperationsFormDTO.InitDefaultOpesRoleDTO role : roles) { |
|
|
|
String roleId = role.getRoleId(); |
|
|
|
String roleKey = role.getRoleKey(); |
|
|
|
String customerId = role.getCustomerId(); |
|
|
|
List<RoleOperationDefaultResultDTO> defaultOperations = roleOperationDefaultDao.listByRoleKey(roleKey); |
|
|
|
if (!CollectionUtils.isEmpty(defaultOperations)) { |
|
|
|
// 有的角色并没有配置默认的操作权限,应该忽略
|
|
|
|
initDefaultOperationsForRole(roleId, defaultOperations); |
|
|
|
initDefaultOperationScopesForRole(roleId, roleKey, defaultOperations); |
|
|
|
initDefaultOperationsForRole(roleId, customerId, defaultOperations); |
|
|
|
initDefaultOperationScopesForRole(roleId, roleKey, customerId, defaultOperations); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -140,13 +141,15 @@ public class RoleOperationServiceImpl extends BaseServiceImpl<RoleOperationDao, |
|
|
|
/** |
|
|
|
* 为某一个角色初始化默认操作权限 |
|
|
|
* @param roleId |
|
|
|
* @param customerId |
|
|
|
* @param operations |
|
|
|
*/ |
|
|
|
public void initDefaultOperationsForRole(String roleId, List<RoleOperationDefaultResultDTO> operations) { |
|
|
|
public void initDefaultOperationsForRole(String roleId, String customerId, List<RoleOperationDefaultResultDTO> operations) { |
|
|
|
for (RoleOperationDefaultResultDTO operation : operations) { |
|
|
|
RoleOperationEntity entity = new RoleOperationEntity(); |
|
|
|
entity.setOperationKey(operation.getOperationKey()); |
|
|
|
entity.setRoleId(roleId); |
|
|
|
entity.setCustomerId(customerId); |
|
|
|
roleOperationDao.insert(entity); |
|
|
|
} |
|
|
|
} |
|
|
@ -157,7 +160,7 @@ public class RoleOperationServiceImpl extends BaseServiceImpl<RoleOperationDao, |
|
|
|
* @param roleId 角色ID |
|
|
|
* @param operations 该角色可以做的操作列表 |
|
|
|
*/ |
|
|
|
public void initDefaultOperationScopesForRole(String roleId, String roleKey, List<RoleOperationDefaultResultDTO> operations) { |
|
|
|
public void initDefaultOperationScopesForRole(String roleId, String roleKey, String customerId, List<RoleOperationDefaultResultDTO> operations) { |
|
|
|
HashMap<String, Set<String>> opeScopeMap = listDefaultOpeScopesMap(roleKey); |
|
|
|
for (RoleOperationDefaultResultDTO operation : operations) { |
|
|
|
// 该角色,该操作的操作范围列表
|
|
|
@ -168,6 +171,7 @@ public class RoleOperationServiceImpl extends BaseServiceImpl<RoleOperationDao, |
|
|
|
roleScopeEntity.setOperationKey(operation.getOperationKey()); |
|
|
|
roleScopeEntity.setRoleId(roleId); |
|
|
|
roleScopeEntity.setScopeKey(scopeKey); |
|
|
|
roleScopeEntity.setCustomerId(customerId); |
|
|
|
roleScopeDao.insert(roleScopeEntity); |
|
|
|
} |
|
|
|
} |
|
|
|