@@ -39,4 +39,14 @@ public interface RegionLimitHelper { | |||||
*/ | */ | ||||
RegionContainsBO getContainsRegionBo(Integer regionLevel, String regionCode); | RegionContainsBO getContainsRegionBo(Integer regionLevel, String regionCode); | ||||
/** | |||||
* 根据专家管理员用户id 获取专家管理员管辖区域列表 | |||||
* | |||||
* @param expertAdminUserId 专家管理员用户id | |||||
* @return | |||||
*/ | |||||
List<RegionContainsBO> getExpertAdminContainsRegion(Long expertAdminUserId); | |||||
} | } |
@@ -5,6 +5,8 @@ import com.ningdatech.pmapi.common.helper.RegionLimitHelper; | |||||
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo; | import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo; | ||||
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; | import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; | ||||
import com.ningdatech.pmapi.meta.model.ExpertRegionInfo; | 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 lombok.AllArgsConstructor; | ||||
import java.util.Objects; | import java.util.Objects; | ||||
@@ -22,6 +24,8 @@ public abstract class AbstractRegionLimitHelper implements RegionLimitHelper { | |||||
protected final RegionCacheHelper regionCache; | protected final RegionCacheHelper regionCache; | ||||
protected final IExpertUserFullInfoService expertUserFullInfoService; | protected final IExpertUserFullInfoService expertUserFullInfoService; | ||||
protected final IUserInfoService iUserInfoService; | |||||
protected final IRegionService regionService; | |||||
/** | /** | ||||
@@ -1,9 +1,16 @@ | |||||
package com.ningdatech.pmapi.common.helper.impl; | 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.RegionCacheHelper; | ||||
import com.ningdatech.pmapi.common.helper.basic.AbstractRegionLimitHelper; | import com.ningdatech.pmapi.common.helper.basic.AbstractRegionLimitHelper; | ||||
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; | import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; | ||||
import com.ningdatech.pmapi.meta.model.bo.RegionContainsBO; | 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.apache.commons.collections4.CollectionUtils; | ||||
import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
@@ -24,8 +31,9 @@ public class RegionLimitHelperImpl extends AbstractRegionLimitHelper { | |||||
private static final Logger logger = LoggerFactory.getLogger(RegionLimitHelperImpl.class); | 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 | 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; | |||||
} | |||||
} | } |
@@ -40,7 +40,7 @@ public class RegionsCacheHelperImpl extends AbstractRegionCacheHelper implements | |||||
@Override | @Override | ||||
public String getRegionName(String code, int level) { | public String getRegionName(String code, int level) { | ||||
RegionDTO dto = getByCodeAndLevel(code, level); | RegionDTO dto = getByCodeAndLevel(code, level); | ||||
if(Objects.nonNull(dto)){ | |||||
if (Objects.nonNull(dto)) { | |||||
return dto.getRegionName(); | return dto.getRegionName(); | ||||
} | } | ||||
return StringUtils.EMPTY; | return StringUtils.EMPTY; | ||||
@@ -54,7 +54,7 @@ public class RegionsCacheHelperImpl extends AbstractRegionCacheHelper implements | |||||
@Override | @Override | ||||
public Collection<String> listChildRegionCodeList(String regionCode, int regionLevel) { | public Collection<String> listChildRegionCodeList(String regionCode, int regionLevel) { | ||||
RegionDTO currRegion = getByCodeAndLevel(regionCode, regionLevel); | RegionDTO currRegion = getByCodeAndLevel(regionCode, regionLevel); | ||||
if(Objects.isNull(currRegion)){ | |||||
if (Objects.isNull(currRegion)) { | |||||
return Collections.emptyList(); | return Collections.emptyList(); | ||||
} | } | ||||
if (currRegion.getParentCode().equals(regionCode)) { | if (currRegion.getParentCode().equals(regionCode)) { | ||||
@@ -217,4 +217,5 @@ public class RegionsCacheHelperImpl extends AbstractRegionCacheHelper implements | |||||
buildUnionPathStrList(regionDTO.getParentCode(), level - 1, unionPathStrList); | buildUnionPathStrList(regionDTO.getParentCode(), level - 1, unionPathStrList); | ||||
} | } | ||||
} | } | ||||
} | } |
@@ -152,6 +152,10 @@ public class ExpertAdminManage { | |||||
} | } | ||||
List<RegionContainsBO> expertAdminContainsRegionList = new ArrayList<>(); | List<RegionContainsBO> expertAdminContainsRegionList = new ArrayList<>(); | ||||
// 如果为超级管理员,可以查看所有的专家,包括没有层级的专家 | |||||
if (!permissionCheckHelper.isSuperAdmin()) { | |||||
expertAdminContainsRegionList = regionLimitHelper.getExpertAdminContainsRegion(userId); | |||||
} | |||||
List<RegionContainsBO> containsRegion = new ArrayList<>(); | List<RegionContainsBO> containsRegion = new ArrayList<>(); | ||||
if (Objects.nonNull(query.getExpertRegionInfo())) { | if (Objects.nonNull(query.getExpertRegionInfo())) { | ||||