Browse Source

是否是区域或者超管

master
PoffyZhang 1 year ago
parent
commit
128940be9c
4 changed files with 21 additions and 10 deletions
  1. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java
  2. +14
    -8
      pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java
  3. +4
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/UserRoleVO.java
  4. +2
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java View File

@@ -28,5 +28,5 @@ public interface UserInfoHelper {
* 判断该用户是否是区管或者超管 * 判断该用户是否是区管或者超管
* @return * @return
*/ */
boolean isAdmin(Long userId);
boolean isSuperOrRegionAdmin(Long userId);
} }

+ 14
- 8
pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java View File

@@ -1,6 +1,9 @@
package com.ningdatech.pmapi.common.helper.impl; package com.ningdatech.pmapi.common.helper.impl;


import cn.hutool.core.collection.CollUtil;
import com.ningdatech.pmapi.common.helper.UserInfoHelper; 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.manage.UserAuthLoginManage;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -38,14 +41,17 @@ public class UserInfoHelperImpl implements UserInfoHelper {
return realName; return realName;
} }


/**
* 判断此人是否是超管或者区管
* @param userId
* @return
*/
@Override @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;
} }
} }

+ 4
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/UserRoleVO.java View File

@@ -1,5 +1,6 @@
package com.ningdatech.pmapi.user.model.vo; package com.ningdatech.pmapi.user.model.vo;


import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@@ -18,4 +19,7 @@ public class UserRoleVO {


@ApiModelProperty(value = "名称") @ApiModelProperty(value = "名称")
private String name; private String name;

@ApiModelProperty(value = "角色code")
private RoleEnum code;
} }

+ 2
- 1
pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java View File

@@ -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.ResToBeProcessedVO;
import com.ningdatech.pmapi.todocenter.model.vo.TodoCenterStatisticsVO; import com.ningdatech.pmapi.todocenter.model.vo.TodoCenterStatisticsVO;
import com.ningdatech.pmapi.todocenter.model.vo.TodoVO; 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.security.auth.model.UserInfoDetails;
import com.ningdatech.pmapi.user.util.LoginUserUtil; import com.ningdatech.pmapi.user.util.LoginUserUtil;
import com.ningdatech.pmapi.workbench.converter.WorkbenchConverter; import com.ningdatech.pmapi.workbench.converter.WorkbenchConverter;
@@ -61,7 +62,7 @@ public class WorkbenchManage {


//2.项目统计数据 //2.项目统计数据
res.setOrgDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectOrgStatistics(year))); res.setOrgDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectOrgStatistics(year)));
if(userInfoHelper.isAdmin(userInfo.getUserId())){
if(userInfoHelper.isSuperOrRegionAdmin(userInfo.getUserId())){
res.setRegionDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectRegionStatistics(year))); res.setRegionDeclared(WorkbenchConverter.convert(defaultDeclaredProjectManage.declaredProjectRegionStatistics(year)));
} }
ProjectListReq projectListReq = new ProjectListReq(); ProjectListReq projectListReq = new ProjectListReq();


Loading…
Cancel
Save