|
@@ -4,6 +4,8 @@ import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.sunxung.factoring.component.util.ConstantConversionUtil;
|
|
|
+import com.sunxung.factoring.service.sys.dto.PermissionDTO;
|
|
|
+import org.apache.commons.compress.utils.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -423,23 +425,32 @@ public class PermissionServiceImpl implements PermissionService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<String> getAllPermissionEname(Long userId) {
|
|
|
+ public PermissionDTO getAllPermissionEname(Long userId) {
|
|
|
|
|
|
List<Role> roleList = roleService.getRoleListByUseId();
|
|
|
- List<String> result = new ArrayList<>();
|
|
|
+ List<String> menuList = new ArrayList<>();
|
|
|
+ List<String> buttonList = new ArrayList<>();
|
|
|
+ List<Permission> permissionList = Lists.newArrayList();
|
|
|
+ boolean isAdmin = false;
|
|
|
for (Role role : roleList) {
|
|
|
if (ConstantConversionUtil.ADMINISTORIES_DISPLAYNAME.equals(role.getName())
|
|
|
|| ConstantConversionUtil.CHILD_ADMINISTORIES_DISPLAYNAME.equals(role.getName())) {
|
|
|
//如果是超级管理员或子管理员角色,默认返回所有
|
|
|
- List<Permission> permissionAllList = permissionMapper.findAll();
|
|
|
- result = permissionAllList.stream().map(Permission::getEname).collect(Collectors.toList());
|
|
|
- return result;
|
|
|
+ permissionList = permissionMapper.findAll();
|
|
|
+ isAdmin = true;
|
|
|
+ // result = permissionAllList.stream().map(Permission::getEname).collect(Collectors.toList());
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- List<Permission> permissionList = permissionMapper.findAllByUserId(userId);
|
|
|
- permissionList.removeAll(Collections.singleton(null));
|
|
|
- result = permissionList.stream().map(Permission::getEname).collect(Collectors.toList());
|
|
|
- return result;
|
|
|
+ if(!isAdmin){
|
|
|
+ permissionList = permissionMapper.findAllByUserId(userId);
|
|
|
+ // permissionList.removeAll(Collections.singleton(null));
|
|
|
+ }
|
|
|
+ menuList = permissionList.stream().filter(x->"menu".equals(x.getType())).map(Permission::getEname).collect(Collectors.toList());
|
|
|
+ buttonList = permissionList.stream().filter(x->"button".equals(x.getType())).map(Permission::getEname).collect(Collectors.toList());
|
|
|
+ PermissionDTO permissionDTO = new PermissionDTO();
|
|
|
+ permissionDTO.setButtons(buttonList);
|
|
|
+ permissionDTO.setMenus(menuList);
|
|
|
+ return permissionDTO;
|
|
|
}
|
|
|
}
|