|
|
@@ -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; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |