소스 검색

增加专家管理员数据权限实现类

master
WendyYang 11 달 전
부모
커밋
b419690525
1개의 변경된 파일74개의 추가작업 그리고 0개의 파일을 삭제
  1. +74
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/ExpertAdminDataScopeProviderImpl.java

+ 74
- 0
pmapi/src/main/java/com/ningdatech/pmapi/datascope/provider/impl/ExpertAdminDataScopeProviderImpl.java 파일 보기

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

}

불러오는 중...
취소
저장