Kaynağa Gözat

fix 专家管理没有数据权限

master
niohe·erbao 1 yıl önce
ebeveyn
işleme
39bc9ebf11
5 değiştirilmiş dosya ile 63 ekleme ve 4 silme
  1. +10
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/helper/RegionLimitHelper.java
  2. +4
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/helper/basic/AbstractRegionLimitHelper.java
  3. +42
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/RegionLimitHelperImpl.java
  4. +3
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/RegionsCacheHelperImpl.java
  5. +4
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertAdminManage.java

+ 10
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/helper/RegionLimitHelper.java Dosyayı Görüntüle

@@ -39,4 +39,14 @@ public interface RegionLimitHelper {
*/
RegionContainsBO getContainsRegionBo(Integer regionLevel, String regionCode);



/**
* 根据专家管理员用户id 获取专家管理员管辖区域列表
*
* @param expertAdminUserId 专家管理员用户id
* @return
*/
List<RegionContainsBO> getExpertAdminContainsRegion(Long expertAdminUserId);

}

+ 4
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/helper/basic/AbstractRegionLimitHelper.java Dosyayı Görüntüle

@@ -5,6 +5,8 @@ import com.ningdatech.pmapi.common.helper.RegionLimitHelper;
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo;
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService;
import com.ningdatech.pmapi.meta.model.ExpertRegionInfo;
import com.ningdatech.pmapi.sys.service.IRegionService;
import com.ningdatech.pmapi.user.service.IUserInfoService;
import lombok.AllArgsConstructor;

import java.util.Objects;
@@ -22,6 +24,8 @@ public abstract class AbstractRegionLimitHelper implements RegionLimitHelper {

protected final RegionCacheHelper regionCache;
protected final IExpertUserFullInfoService expertUserFullInfoService;
protected final IUserInfoService iUserInfoService;
protected final IRegionService regionService;


/**


+ 42
- 2
pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/RegionLimitHelperImpl.java Dosyayı Görüntüle

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

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.pmapi.common.helper.RegionCacheHelper;
import com.ningdatech.pmapi.common.helper.basic.AbstractRegionLimitHelper;
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService;
import com.ningdatech.pmapi.meta.model.bo.RegionContainsBO;
import com.ningdatech.pmapi.sys.model.entity.Region;
import com.ningdatech.pmapi.sys.service.IRegionService;
import com.ningdatech.pmapi.user.entity.UserInfo;
import com.ningdatech.pmapi.user.service.IUserInfoService;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -24,8 +31,9 @@ public class RegionLimitHelperImpl extends AbstractRegionLimitHelper {

private static final Logger logger = LoggerFactory.getLogger(RegionLimitHelperImpl.class);

public RegionLimitHelperImpl(RegionCacheHelper regionCache, IExpertUserFullInfoService expertUserFullInfoService) {
super(regionCache, expertUserFullInfoService);
public RegionLimitHelperImpl(RegionCacheHelper regionCache, IExpertUserFullInfoService expertUserFullInfoService
, IUserInfoService iUserInfoService, IRegionService regionService) {
super(regionCache, expertUserFullInfoService, iUserInfoService, regionService);
}

public static Boolean contains(Integer adminRegionLevel, List<String> adminAllContainsRegionCodes
@@ -89,4 +97,36 @@ public class RegionLimitHelperImpl extends AbstractRegionLimitHelper {
}


@Override
public List<RegionContainsBO> getExpertAdminContainsRegion(Long expertAdminUserId) {
if (Objects.isNull(expertAdminUserId)) {
logger.error("getExpertAdminContainsRegion expertAdminUserId is null");
return new ArrayList<>();
}

UserInfo userInfo = iUserInfoService.getById(expertAdminUserId);

if (Objects.isNull(userInfo) || StringUtils.isBlank(userInfo.getRegionCode())) {
logger.error("getExpertAdminContainsRegion userInfo is null Or regionCode is null");
return new ArrayList<>();
}

String regionCode = userInfo.getRegionCode();
List<Region> regionList = regionService.list(Wrappers.lambdaQuery(Region.class)
.eq(Region::getRegionCode, regionCode)
.orderByDesc(Region::getRegionLevel));

Region region = regionList.get(0);
Collection<String> regionCodes = regionCache
.listChildRegionCodeList(region.getRegionCode(), region.getRegionLevel());
RegionContainsBO regionContainsBO = new RegionContainsBO();
regionContainsBO.setContainsRegionCodeList(new ArrayList<>(regionCodes));
regionContainsBO.setParentRegionTreeLevel(region.getRegionLevel());

ArrayList<RegionContainsBO> regionContainsBOS = CollectionUtil.toList(regionContainsBO);

return regionContainsBOS;
}


}

+ 3
- 2
pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/RegionsCacheHelperImpl.java Dosyayı Görüntüle

@@ -40,7 +40,7 @@ public class RegionsCacheHelperImpl extends AbstractRegionCacheHelper implements
@Override
public String getRegionName(String code, int level) {
RegionDTO dto = getByCodeAndLevel(code, level);
if(Objects.nonNull(dto)){
if (Objects.nonNull(dto)) {
return dto.getRegionName();
}
return StringUtils.EMPTY;
@@ -54,7 +54,7 @@ public class RegionsCacheHelperImpl extends AbstractRegionCacheHelper implements
@Override
public Collection<String> listChildRegionCodeList(String regionCode, int regionLevel) {
RegionDTO currRegion = getByCodeAndLevel(regionCode, regionLevel);
if(Objects.isNull(currRegion)){
if (Objects.isNull(currRegion)) {
return Collections.emptyList();
}
if (currRegion.getParentCode().equals(regionCode)) {
@@ -217,4 +217,5 @@ public class RegionsCacheHelperImpl extends AbstractRegionCacheHelper implements
buildUnionPathStrList(regionDTO.getParentCode(), level - 1, unionPathStrList);
}
}

}

+ 4
- 0
pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertAdminManage.java Dosyayı Görüntüle

@@ -152,6 +152,10 @@ public class ExpertAdminManage {
}

List<RegionContainsBO> expertAdminContainsRegionList = new ArrayList<>();
// 如果为超级管理员,可以查看所有的专家,包括没有层级的专家
if (!permissionCheckHelper.isSuperAdmin()) {
expertAdminContainsRegionList = regionLimitHelper.getExpertAdminContainsRegion(userId);
}

List<RegionContainsBO> containsRegion = new ArrayList<>();
if (Objects.nonNull(query.getExpertRegionInfo())) {


Yükleniyor…
İptal
Kaydet