diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java index cad7b59..5b0f5f1 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java @@ -28,5 +28,5 @@ public interface UserInfoHelper { * 判断该用户是否是区管或者超管 * @return */ - boolean isAdmin(Long userId); + boolean isSuperOrRegionAdmin(Long userId); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java index d0fba73..da94912 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java @@ -1,6 +1,9 @@ package com.ningdatech.pmapi.common.helper.impl; +import cn.hutool.core.collection.CollUtil; import com.ningdatech.pmapi.common.helper.UserInfoHelper; +import com.ningdatech.pmapi.sys.model.entity.Role; +import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; import com.ningdatech.pmapi.user.manage.UserAuthLoginManage; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import lombok.RequiredArgsConstructor; @@ -38,14 +41,17 @@ public class UserInfoHelperImpl implements UserInfoHelper { return realName; } - /** - * 判断此人是否是超管或者区管 - * @param userId - * @return - */ @Override - public boolean isAdmin(Long userId) { - //测试 先返回true - return Boolean.TRUE; + public boolean isSuperOrRegionAdmin(Long userId) { + UserFullInfoDTO userFullInfo = userAuthLoginManage.getUserFullInfo(userId); + if(CollUtil.isNotEmpty(userFullInfo.getUserRoleList())){ + for(Role role : userFullInfo.getUserRoleList()){ + if(RoleEnum.SUPER_ADMIN.equals(role.getCode()) || + RoleEnum.REGION_ADMIN.equals(role.getCode()) ){ + return Boolean.TRUE; + } + } + } + return Boolean.FALSE; } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/UserRoleVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/UserRoleVO.java index 50cc474..ec9844a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/UserRoleVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/UserRoleVO.java @@ -1,5 +1,6 @@ package com.ningdatech.pmapi.user.model.vo; +import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -18,4 +19,7 @@ public class UserRoleVO { @ApiModelProperty(value = "名称") private String name; + + @ApiModelProperty(value = "角色code") + private RoleEnum code; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java index 81cde72..ee44843 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java @@ -17,6 +17,7 @@ import com.ningdatech.pmapi.todocenter.model.req.ToBeProcessedReq; import com.ningdatech.pmapi.todocenter.model.vo.ResToBeProcessedVO; import com.ningdatech.pmapi.todocenter.model.vo.TodoCenterStatisticsVO; import com.ningdatech.pmapi.todocenter.model.vo.TodoVO; +import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; import com.ningdatech.pmapi.user.util.LoginUserUtil; import com.ningdatech.pmapi.workbench.converter.WorkbenchConverter; @@ -61,7 +62,7 @@ public class WorkbenchManage { //2.项目统计数据 res.setOrgDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectOrgStatistics(year))); - if(userInfoHelper.isAdmin(userInfo.getUserId())){ + if(userInfoHelper.isSuperOrRegionAdmin(userInfo.getUserId())){ res.setRegionDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectRegionStatistics(year))); } ProjectListReq projectListReq = new ProjectListReq();