|
|
@@ -94,6 +94,7 @@ public class RoleServiceImpl extends CommonBaseServiceImpl<RoleMapper, Role> imp
|
|
|
List<Map<String, Object>> classifyList = roleResourceMapper.selectClassifyByRoleId(id);
|
|
|
List<PowerInfo> powerInfoList = roleResourceMapper.selectPowerInfo();
|
|
|
List<OtherPower> otherPowerList = roleResourceMapper.selectOthersPower();
|
|
|
+ List<OtherPower> hasOtherPowerList = roleResourceMapper.selectOthersPowerByRoleId(id);
|
|
|
|
|
|
for (PowerInfo powerInfo : powerInfoList){
|
|
|
PowerDTO powerDTO = new PowerDTO();
|
|
|
@@ -103,6 +104,7 @@ public class RoleServiceImpl extends CommonBaseServiceImpl<RoleMapper, Role> imp
|
|
|
powerDTO.setModuleId(powerInfo.getModuleId());
|
|
|
//赋值默认权限,在权限列表中的资源默认置为false
|
|
|
setPowerValue(powerDTO, powerInfo.getClassify(), false);
|
|
|
+ setDefaultOtherPower(powerDTO, powerDTO.getGroupId(), id, otherPowerList);
|
|
|
//赋值权限
|
|
|
for (Map<String, Object> map : classifyList){
|
|
|
if (powerInfo.getGrougId().equals(map.get("group_id"))){
|
|
|
@@ -111,7 +113,7 @@ public class RoleServiceImpl extends CommonBaseServiceImpl<RoleMapper, Role> imp
|
|
|
setPowerValue(powerDTO, classify, true);
|
|
|
}
|
|
|
//设置其他权限
|
|
|
- setOtherPower(powerDTO, powerInfo.getGrougId(), id, otherPowerList);
|
|
|
+ setOtherPower(powerDTO, hasOtherPowerList);
|
|
|
}
|
|
|
powerDTOList.add(powerDTO);
|
|
|
}
|
|
|
@@ -164,10 +166,17 @@ public class RoleServiceImpl extends CommonBaseServiceImpl<RoleMapper, Role> imp
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- private void setOtherPower(PowerDTO powerDTO, Long groupId, Long roleId, List<OtherPower> otherPowerList) {
|
|
|
+ /**
|
|
|
+ * 设置其他默认权限,用于生成设置按钮
|
|
|
+ * @param powerDTO
|
|
|
+ * @param groupId
|
|
|
+ * @param roleId
|
|
|
+ * @param otherPowerList
|
|
|
+ */
|
|
|
+ private void setDefaultOtherPower(PowerDTO powerDTO, Long groupId, Long roleId, List<OtherPower> otherPowerList){
|
|
|
List<OtherPower> otherPowers = new ArrayList<OtherPower>();
|
|
|
for (OtherPower otherPower : otherPowerList){
|
|
|
- if (groupId.equals(otherPower.getGroupId()) && roleId.equals(otherPower.getRoleId())){
|
|
|
+ if (groupId.equals(otherPower.getGroupId())){
|
|
|
otherPowers.add(otherPower);
|
|
|
}
|
|
|
}
|
|
|
@@ -175,6 +184,20 @@ public class RoleServiceImpl extends CommonBaseServiceImpl<RoleMapper, Role> imp
|
|
|
powerDTO.setOther(otherPowerDTOList);
|
|
|
}
|
|
|
|
|
|
+ private void setOtherPower(PowerDTO powerDTO, List<OtherPower> otherPowerList) {
|
|
|
+ List<OtherPowerDTO> otherPowers = powerDTO.getOther();
|
|
|
+ if (!CollectionUtils.isEmpty(otherPowers)) {
|
|
|
+ for (OtherPower otherPower : otherPowerList) {
|
|
|
+ for (OtherPowerDTO otherPowerDTO : otherPowers) {
|
|
|
+ if (otherPowerDTO.getResourceId().equals(otherPower.getResourceId())) {
|
|
|
+ otherPowerDTO.setChecked(otherPower.isChecked());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ powerDTO.setOther(otherPowers);
|
|
|
+ }
|
|
|
+
|
|
|
private void setPowerValue(PowerDTO powerDTO, String classify , boolean status) {
|
|
|
String[] array = classify.split(",");
|
|
|
for(int i = 0; i < array.length; i++){
|