返回前端的角色中增加编码信息

This commit is contained in:
Zhaoyang 2020-02-24 09:33:38 +08:00
parent 4c549a934d
commit 1311cfaa89
2 changed files with 9 additions and 1 deletions

View File

@ -25,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 系统用户相关Service实现
@ -55,9 +56,11 @@ public class IamUserServiceImpl extends BaseIamServiceImpl<IamUserMapper, IamUse
attachExtraPermissions(roleVOList);
// 对RoleList做聚合处理以适配前端
List<String> nameList = new ArrayList<>();
List<String> codeList = new ArrayList<>();
List<IamPermission> allPermissionList = new ArrayList<>();
roleVOList.forEach(vo -> {
nameList.add(vo.getName());
codeList.add(vo.getCode());
if (V.notEmpty(vo.getPermissionList())){
allPermissionList.addAll(vo.getPermissionList());
}
@ -66,6 +69,7 @@ public class IamUserServiceImpl extends BaseIamServiceImpl<IamUserMapper, IamUse
List permissionList = BeanUtils.distinctByKey(allPermissionList, IamPermission::getId);
IamRoleVO roleVO = new IamRoleVO();
roleVO.setName(S.join(nameList));
roleVO.setCode(S.join(codeList));
roleVO.setPermissionList(permissionList);
return roleVO;

View File

@ -1,6 +1,7 @@
package com.diboot.iam.vo;
import com.diboot.core.binding.annotation.BindEntityList;
import com.diboot.core.util.V;
import com.diboot.iam.config.Cons;
import com.diboot.iam.entity.IamPermission;
import com.diboot.iam.entity.IamRole;
@ -27,7 +28,10 @@ public class IamRoleVO extends IamRole {
* @return
*/
public boolean isSuperAdmin(){
return Cons.ROLE_SUPER_ADMIN.equals(getCode());
if (V.isEmpty(getCode())){
return false;
}
return getCode().contains(Cons.ROLE_SUPER_ADMIN + ",") || getCode().contains("," + Cons.ROLE_SUPER_ADMIN) || Cons.ROLE_SUPER_ADMIN.equals(getCode());
}
}