|
@@ -1,9 +1,7 @@
|
|
|
package com.usoftchina.saas.account.service.impl;
|
|
package com.usoftchina.saas.account.service.impl;
|
|
|
|
|
|
|
|
import com.usoftchina.saas.account.constant.RoleType;
|
|
import com.usoftchina.saas.account.constant.RoleType;
|
|
|
-import com.usoftchina.saas.account.dto.OtherPowerDTO;
|
|
|
|
|
-import com.usoftchina.saas.account.dto.PowerDTO;
|
|
|
|
|
-import com.usoftchina.saas.account.dto.RoleBaseDTO;
|
|
|
|
|
|
|
+import com.usoftchina.saas.account.dto.*;
|
|
|
import com.usoftchina.saas.account.mapper.*;
|
|
import com.usoftchina.saas.account.mapper.*;
|
|
|
import com.usoftchina.saas.account.po.*;
|
|
import com.usoftchina.saas.account.po.*;
|
|
|
import com.usoftchina.saas.account.service.ResourceService;
|
|
import com.usoftchina.saas.account.service.ResourceService;
|
|
@@ -94,7 +92,7 @@ public class RoleServiceImpl extends CommonBaseServiceImpl<RoleMapper, Role> imp
|
|
|
public List<PowerDTO> getResourcePowerById(Long id) {
|
|
public List<PowerDTO> getResourcePowerById(Long id) {
|
|
|
List<PowerDTO> powerDTOList = new ArrayList<PowerDTO>();
|
|
List<PowerDTO> powerDTOList = new ArrayList<PowerDTO>();
|
|
|
List<Map<String, Object>> classifyList = roleResourceMapper.selectClassifyByRoleId(id);
|
|
List<Map<String, Object>> classifyList = roleResourceMapper.selectClassifyByRoleId(id);
|
|
|
- List<OtherPower> otherPowerList = roleResourceMapper.selectOthersPower(id);
|
|
|
|
|
|
|
+ List<OtherPower> otherPowerList = roleResourceMapper.selectOthersPower();
|
|
|
//查询所有模块
|
|
//查询所有模块
|
|
|
List<ResourceModule> modules = resourceModuleMapper.selectByAppId(BaseContextHolder.getAppId());
|
|
List<ResourceModule> modules = resourceModuleMapper.selectByAppId(BaseContextHolder.getAppId());
|
|
|
for (ResourceModule module : modules){
|
|
for (ResourceModule module : modules){
|
|
@@ -110,9 +108,7 @@ public class RoleServiceImpl extends CommonBaseServiceImpl<RoleMapper, Role> imp
|
|
|
if (group.getId().equals(map.get("group_id"))){
|
|
if (group.getId().equals(map.get("group_id"))){
|
|
|
String classify = String.valueOf(map.get("classify"));
|
|
String classify = String.valueOf(map.get("classify"));
|
|
|
setPowerValue(powerDTO, classify);
|
|
setPowerValue(powerDTO, classify);
|
|
|
- if (classify.contains("OTHER")){
|
|
|
|
|
- setOtherPower(powerDTO, group.getId(), otherPowerList);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ setOtherPower(powerDTO, group.getId(), id, otherPowerList);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
powerDTOList.add(powerDTO);
|
|
powerDTOList.add(powerDTO);
|
|
@@ -121,10 +117,56 @@ public class RoleServiceImpl extends CommonBaseServiceImpl<RoleMapper, Role> imp
|
|
|
return powerDTOList;
|
|
return powerDTOList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void setOtherPower(PowerDTO powerDTO, Long groupId, List<OtherPower> otherPowerList) {
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean saveRoleResource(PowerSetListDTO powerSetListDTO) {
|
|
|
|
|
+ Long roleId = powerSetListDTO.getRoleId();
|
|
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
|
|
+ String appId = BaseContextHolder.getAppId();
|
|
|
|
|
+ List<RoleResource> addRoleResourceList = new ArrayList<RoleResource>();
|
|
|
|
|
+ List<RoleResource> delRoleResourceList = new ArrayList<RoleResource>();
|
|
|
|
|
+
|
|
|
|
|
+ for (PowerSetDTO powerSetDTO : powerSetListDTO.getPowerSetList()){
|
|
|
|
|
+ List<Resource> resourceList = resourceMapper.selectByGroupId(powerSetDTO.getGroupId());
|
|
|
|
|
+ if (powerSetDTO.isChecked()) {
|
|
|
|
|
+ if (powerSetDTO.getGroupId() != null && powerSetDTO.getResourceId() == null) {
|
|
|
|
|
+ for (Resource resource : resourceList){
|
|
|
|
|
+ if (resource.getClassify().equalsIgnoreCase(powerSetDTO.getClassify())){
|
|
|
|
|
+ RoleResource roleResource = new RoleResource(roleId, appId, resource.getId(), companyId);
|
|
|
|
|
+ addRoleResourceList.add(roleResource);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (powerSetDTO.getResourceId() != null && powerSetDTO.getGroupId() == null) {
|
|
|
|
|
+ roleResourceMapper.delete(roleId, powerSetDTO.getResourceId());
|
|
|
|
|
+ RoleResource roleResource = new RoleResource(roleId, appId, powerSetDTO.getResourceId(), companyId);
|
|
|
|
|
+ addRoleResourceList.add(roleResource);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ if (powerSetDTO.getGroupId() != null && powerSetDTO.getResourceId() == null) {
|
|
|
|
|
+ for (Resource resource : resourceList){
|
|
|
|
|
+ if (resource.getClassify().equalsIgnoreCase(powerSetDTO.getClassify())){
|
|
|
|
|
+ RoleResource roleResource = new RoleResource(roleId, appId, resource.getId(), companyId);
|
|
|
|
|
+ delRoleResourceList.add(roleResource);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (powerSetDTO.getResourceId() != null && powerSetDTO.getGroupId() == null) {
|
|
|
|
|
+ RoleResource roleResource = new RoleResource(roleId, appId, powerSetDTO.getResourceId(), companyId);
|
|
|
|
|
+ delRoleResourceList.add(roleResource);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for (RoleResource roleResource : delRoleResourceList) {
|
|
|
|
|
+ roleResourceMapper.delete(roleResource.getRoleId(), roleResource.getResourceId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (addRoleResourceList.size() > 0) {
|
|
|
|
|
+ roleResourceMapper.batchInsert(addRoleResourceList);
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void setOtherPower(PowerDTO powerDTO, Long groupId, Long roleId, List<OtherPower> otherPowerList) {
|
|
|
List<OtherPower> otherPowers = new ArrayList<OtherPower>();
|
|
List<OtherPower> otherPowers = new ArrayList<OtherPower>();
|
|
|
for (OtherPower otherPower : otherPowerList){
|
|
for (OtherPower otherPower : otherPowerList){
|
|
|
- if (otherPower.getGroupId().equals(groupId)){
|
|
|
|
|
|
|
+ if (groupId.equals(otherPower.getGroupId())){
|
|
|
otherPowers.add(otherPower);
|
|
otherPowers.add(otherPower);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -138,6 +180,7 @@ public class RoleServiceImpl extends CommonBaseServiceImpl<RoleMapper, Role> imp
|
|
|
switch (array[i]){
|
|
switch (array[i]){
|
|
|
case "QUERY":
|
|
case "QUERY":
|
|
|
powerDTO.setQuery(true);
|
|
powerDTO.setQuery(true);
|
|
|
|
|
+ powerDTO.setFileExport(true);
|
|
|
break;
|
|
break;
|
|
|
case "ADD":
|
|
case "ADD":
|
|
|
powerDTO.setAdd(true);
|
|
powerDTO.setAdd(true);
|