|
@@ -0,0 +1,74 @@ |
|
|
|
|
|
package com.ningdatech.pmapi.datascope.provider.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
|
|
|
import com.ningdatech.pmapi.common.helper.RegionCacheHelper; |
|
|
|
|
|
import com.ningdatech.pmapi.common.helper.UserInfoHelper; |
|
|
|
|
|
import com.ningdatech.pmapi.datascope.model.DataScopeDTO; |
|
|
|
|
|
import com.ningdatech.pmapi.datascope.provider.DataScopeProvider; |
|
|
|
|
|
import com.ningdatech.pmapi.sys.model.dto.RegionDTO; |
|
|
|
|
|
import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; |
|
|
|
|
|
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 lombok.RequiredArgsConstructor; |
|
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
import java.util.Optional; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* <p> |
|
|
|
|
|
* ExpertAdminDataScopeProviderImpl |
|
|
|
|
|
* </p> |
|
|
|
|
|
* |
|
|
|
|
|
* @author WendyYang |
|
|
|
|
|
* @since 10:39 2023/12/11 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Component("EXPERT_ADMIN") |
|
|
|
|
|
@RequiredArgsConstructor |
|
|
|
|
|
public class ExpertAdminDataScopeProviderImpl implements DataScopeProvider { |
|
|
|
|
|
|
|
|
|
|
|
private final RegionCacheHelper regionCacheHelper; |
|
|
|
|
|
private final UserInfoHelper userInfoHelper; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Optional<DataScopeDTO> findDataFieldProperty() { |
|
|
|
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
|
|
|
DataScopeDTO ds = new DataScopeDTO(); |
|
|
|
|
|
if (Objects.isNull(user.getRegionLevel())) { |
|
|
|
|
|
ds.setRegionIds(Collections.emptyList()); |
|
|
|
|
|
ds.setRegionCodes(Collections.emptyList()); |
|
|
|
|
|
} else { |
|
|
|
|
|
List<RegionDTO> regions = regionCacheHelper.listChildren(user.getRegionCode(), user.getRegionLevel()); |
|
|
|
|
|
ds.setRegionCodes(CollUtils.fieldList(regions, RegionDTO::getRegionCode)); |
|
|
|
|
|
ds.setRegionIds(CollUtils.fieldList(regions, RegionDTO::getId)); |
|
|
|
|
|
} |
|
|
|
|
|
ds.setRole(RoleEnum.EXPERT_ADMIN); |
|
|
|
|
|
ds.setUserId(user.getUserId()); |
|
|
|
|
|
ds.setEmployeeCode(user.getEmployeeCode()); |
|
|
|
|
|
ds.setOrgCode(user.getOrganizationCode()); |
|
|
|
|
|
return Optional.of(ds); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Optional<DataScopeDTO> findDataFieldProperty(Long userId) { |
|
|
|
|
|
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(userId); |
|
|
|
|
|
DataScopeDTO ds = new DataScopeDTO(); |
|
|
|
|
|
if (Objects.isNull(user.getRegionLevel())) { |
|
|
|
|
|
ds.setRegionIds(Collections.emptyList()); |
|
|
|
|
|
ds.setRegionCodes(Collections.emptyList()); |
|
|
|
|
|
} else { |
|
|
|
|
|
List<RegionDTO> regions = regionCacheHelper.listChildren(user.getRegionCode(), user.getRegionLevel()); |
|
|
|
|
|
ds.setRegionCodes(CollUtils.fieldList(regions, RegionDTO::getRegionCode)); |
|
|
|
|
|
ds.setRegionIds(CollUtils.fieldList(regions, RegionDTO::getId)); |
|
|
|
|
|
} |
|
|
|
|
|
ds.setRole(RoleEnum.EXPERT_ADMIN); |
|
|
|
|
|
ds.setUserId(user.getUserId()); |
|
|
|
|
|
ds.setEmployeeCode(user.getEmployeeCode()); |
|
|
|
|
|
ds.setOrgCode(user.getOrganizationCode()); |
|
|
|
|
|
return Optional.of(ds); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |