【update】数据权限部分业务逻辑修改
This commit is contained in:
parent
e80b644f62
commit
7db999404b
|
@ -21,6 +21,5 @@ public class UserRes {
|
||||||
private String rankCode;
|
private String rankCode;
|
||||||
private String companyCode;
|
private String companyCode;
|
||||||
private String workStatus;
|
private String workStatus;
|
||||||
private List<SystemOrganizationVO> roleOrgList;
|
|
||||||
private List<Role> roleList;
|
private List<Role> roleList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,8 +82,6 @@ public class User implements Serializable {
|
||||||
@Transient
|
@Transient
|
||||||
private List<String> roleOrgCodeList;
|
private List<String> roleOrgCodeList;
|
||||||
@Transient
|
@Transient
|
||||||
private List<SystemOrganizationVO> roleOrgList;
|
|
||||||
@Transient
|
|
||||||
private List<Role> roleList;
|
private List<Role> roleList;
|
||||||
|
|
||||||
public User loadInfoFromDept() {
|
public User loadInfoFromDept() {
|
||||||
|
|
|
@ -26,4 +26,6 @@ public interface SystemOrganizationRepository {
|
||||||
SystemOrganization queryChild(SystemOrganization systemOrganization);
|
SystemOrganization queryChild(SystemOrganization systemOrganization);
|
||||||
|
|
||||||
List<SystemOrganization> expandOrganizations(List<SystemOrganization> systemOrganizations);
|
List<SystemOrganization> expandOrganizations(List<SystemOrganization> systemOrganizations);
|
||||||
|
|
||||||
|
List<String> queryOrgCodeListByUserId(Long userId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
|
@ -94,43 +95,56 @@ public class RoleRepositoryImpl implements RoleRepository {
|
||||||
Long userId = user.getUserId();
|
Long userId = user.getUserId();
|
||||||
List<String> orgCodeList = cacheRoleRepository
|
List<String> orgCodeList = cacheRoleRepository
|
||||||
.roleOrgCodeList(userId, null);
|
.roleOrgCodeList(userId, null);
|
||||||
List<SystemOrganizationVO> systemOrganizationVOList = cacheRoleRepository
|
if (orgCodeList == null) {
|
||||||
.roleOrgList(userId, null);
|
orgCodeList=systemOrganizationRepository.queryOrgCodeListByUserId(userId);
|
||||||
|
if (!orgCodeList.isEmpty()) {
|
||||||
if (systemOrganizationVOList == null || systemOrganizationVOList.isEmpty() ||
|
orgCodeList=orgCodeList.stream().filter(Objects::nonNull).toList();
|
||||||
orgCodeList == null || orgCodeList.isEmpty()) {
|
}
|
||||||
List<Role> roleList = user.getRoleList();
|
|
||||||
List<Long> orgListId = roleList
|
|
||||||
.stream()
|
|
||||||
.flatMap(role -> role.getRoleOrganizationList().stream())
|
|
||||||
.map(RoleOrganization::getOrgId)
|
|
||||||
.distinct()
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
// 获取所有的 SystemOrganization
|
|
||||||
List<SystemOrganization> rootOrganizations = systemOrganizationRepository.findByIdIn(orgListId);
|
|
||||||
|
|
||||||
// 展开所有的 SystemOrganization
|
|
||||||
rootOrganizations = systemOrganizationRepository.expandOrganizations(rootOrganizations);
|
|
||||||
|
|
||||||
orgCodeList = rootOrganizations.stream()
|
|
||||||
.map(SystemOrganization::getOrgShortCode)
|
|
||||||
.distinct()
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
systemOrganizationVOList = rootOrganizations.stream()
|
|
||||||
.map(SystemOrganization::mapToVO)
|
|
||||||
.distinct()
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
cacheRoleRepository.evictRoleOrgCodeList(userId);
|
cacheRoleRepository.evictRoleOrgCodeList(userId);
|
||||||
cacheRoleRepository.roleOrgCodeList(userId, orgCodeList);
|
cacheRoleRepository.roleOrgCodeList(userId, orgCodeList);
|
||||||
cacheRoleRepository.evictRoleOrgList(userId);
|
|
||||||
cacheRoleRepository.roleOrgList(userId, systemOrganizationVOList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置用户的角色组织列表
|
|
||||||
user.setRoleOrgCodeList(orgCodeList);
|
user.setRoleOrgCodeList(orgCodeList);
|
||||||
user.setRoleOrgList(systemOrganizationVOList);
|
|
||||||
|
|
||||||
|
// List<String> orgCodeList = cacheRoleRepository
|
||||||
|
// .roleOrgCodeList(userId, null);
|
||||||
|
// List<SystemOrganizationVO> systemOrganizationVOList = cacheRoleRepository
|
||||||
|
// .roleOrgList(userId, null);
|
||||||
|
//
|
||||||
|
// if (systemOrganizationVOList == null || systemOrganizationVOList.isEmpty() ||
|
||||||
|
// orgCodeList == null || orgCodeList.isEmpty()) {
|
||||||
|
// List<Role> roleList = user.getRoleList();
|
||||||
|
// List<Long> orgListId = roleList
|
||||||
|
// .stream()
|
||||||
|
// .flatMap(role -> role.getRoleOrganizationList().stream())
|
||||||
|
// .map(RoleOrganization::getOrgId)
|
||||||
|
// .distinct()
|
||||||
|
// .toList();
|
||||||
|
//
|
||||||
|
// // 获取所有的 SystemOrganization
|
||||||
|
// List<SystemOrganization> rootOrganizations = systemOrganizationRepository.findByIdIn(orgListId);
|
||||||
|
//
|
||||||
|
// // 展开所有的 SystemOrganization
|
||||||
|
// rootOrganizations = systemOrganizationRepository.expandOrganizations(rootOrganizations);
|
||||||
|
//
|
||||||
|
// orgCodeList = rootOrganizations.stream()
|
||||||
|
// .map(SystemOrganization::getOrgShortCode)
|
||||||
|
// .distinct()
|
||||||
|
// .toList();
|
||||||
|
//
|
||||||
|
// systemOrganizationVOList = rootOrganizations.stream()
|
||||||
|
// .map(SystemOrganization::mapToVO)
|
||||||
|
// .distinct()
|
||||||
|
// .toList();
|
||||||
|
//
|
||||||
|
// cacheRoleRepository.evictRoleOrgCodeList(userId);
|
||||||
|
// cacheRoleRepository.roleOrgCodeList(userId, orgCodeList);
|
||||||
|
// cacheRoleRepository.evictRoleOrgList(userId);
|
||||||
|
// cacheRoleRepository.roleOrgList(userId, systemOrganizationVOList);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 设置用户的角色组织列表
|
||||||
|
// user.setRoleOrgCodeList(orgCodeList);
|
||||||
|
// user.setRoleOrgList(systemOrganizationVOList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,6 +127,11 @@ public class SystemOrganizationRepositoryImpl implements SystemOrganizationRepos
|
||||||
return allOrganizations;
|
return allOrganizations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> queryOrgCodeListByUserId(Long userId) {
|
||||||
|
return jdbcSystemOrganizationRepository.queryOrgCodeListByUserId(userId);
|
||||||
|
}
|
||||||
|
|
||||||
private void expandOrganizationRecursively(SystemOrganization org,
|
private void expandOrganizationRecursively(SystemOrganization org,
|
||||||
List<SystemOrganization> allOrganizations) {
|
List<SystemOrganization> allOrganizations) {
|
||||||
if (org == null) {
|
if (org == null) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.chint.infrastructure.repository.jdbc;
|
package com.chint.infrastructure.repository.jdbc;
|
||||||
|
|
||||||
import com.chint.domain.aggregates.system.SystemOrganization;
|
import com.chint.domain.aggregates.system.SystemOrganization;
|
||||||
|
import org.springframework.data.jdbc.repository.query.Query;
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@ -15,4 +16,10 @@ public interface JdbcSystemOrganizationRepository extends CrudRepository<SystemO
|
||||||
List<SystemOrganization> findByOrgLevelIsNullOrOrgLevel(String orgLevel);
|
List<SystemOrganization> findByOrgLevelIsNullOrOrgLevel(String orgLevel);
|
||||||
List<SystemOrganization> findByOrgShortCodeIn(Collection<String> orgCode);
|
List<SystemOrganization> findByOrgShortCodeIn(Collection<String> orgCode);
|
||||||
List<SystemOrganization> findByIdIn(Collection<Long> id);
|
List<SystemOrganization> findByIdIn(Collection<Long> id);
|
||||||
|
|
||||||
|
@Query("select so.org_short_code from role_organization ro,system_organization so,role_user ru " +
|
||||||
|
"where ro.org_id = so.id " +
|
||||||
|
"and ro.role_id = ru.role_id " +
|
||||||
|
"and ru.user_id = :#{#userId}")
|
||||||
|
List<String> queryOrgCodeListByUserId(Long userId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,8 @@ public interface JdbcOrderDetailBasicRepository extends CrudRepository<OrderDeta
|
||||||
|
|
||||||
|
|
||||||
@Query("SELECT * FROM order_detail " +
|
@Query("SELECT * FROM order_detail " +
|
||||||
// "WHERE route_id IN (:#{#dto.routeIds}) " +
|
"WHERE route_id IN (:#{#dto.routeIds}) " +
|
||||||
"WHERE 1=1 " +
|
// "WHERE 1=1 " +
|
||||||
"AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " +
|
"AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " +
|
||||||
"AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime}) " +
|
"AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime}) " +
|
||||||
"AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) " +
|
"AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) " +
|
||||||
|
@ -48,8 +48,8 @@ public interface JdbcOrderDetailBasicRepository extends CrudRepository<OrderDeta
|
||||||
List<OrderDetailBasic> listByCondition(@Param("dto") OrderPageQuery dto, @Param("pageRequest") PageRequest pageRequest);
|
List<OrderDetailBasic> listByCondition(@Param("dto") OrderPageQuery dto, @Param("pageRequest") PageRequest pageRequest);
|
||||||
|
|
||||||
@Query("SELECT COUNT(*) FROM order_detail " +
|
@Query("SELECT COUNT(*) FROM order_detail " +
|
||||||
// "WHERE route_id IN (:#{#dto.routeIds}) " +
|
"WHERE route_id IN (:#{#dto.routeIds}) " +
|
||||||
"WHERE 1=1 " +
|
// "WHERE 1=1 " +
|
||||||
"AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " +
|
"AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " +
|
||||||
"AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime} ) " +
|
"AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime} ) " +
|
||||||
"AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) "+
|
"AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) "+
|
||||||
|
|
|
@ -21,6 +21,6 @@ public interface JdbcOrderExceedStandardRepository extends CrudRepository<OrderE
|
||||||
|
|
||||||
List<OrderExceedStandard> findAll();
|
List<OrderExceedStandard> findAll();
|
||||||
|
|
||||||
// Page<OrderExceedStandard> findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContainsAndOrderNoIn(String applicant, String company, String actualOrderNo, String orderNo, List<String> orderNos, Pageable pageable);
|
Page<OrderExceedStandard> findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContainsAndOrderNoIn(String applicant, String company, String actualOrderNo, String orderNo, List<String> orderNos, Pageable pageable);
|
||||||
Page<OrderExceedStandard> findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContains(String applicant, String company, String actualOrderNo, String orderNo, Pageable pageable);
|
//Page<OrderExceedStandard> findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContains(String applicant, String company, String actualOrderNo, String orderNo, Pageable pageable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,10 +80,10 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
|
||||||
@Override
|
@Override
|
||||||
public PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailQuery dto) {
|
public PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailQuery dto) {
|
||||||
//数据权限
|
//数据权限
|
||||||
// List<Long> orderIds=baseUtil.getOrderIds();
|
List<Long> orderIds=baseUtil.getOrderIds();
|
||||||
// if (orderIds==null||orderIds.isEmpty()) {
|
if (orderIds==null||orderIds.isEmpty()) {
|
||||||
// return PageResult.totalPageNum(0, new ArrayList<>());
|
return PageResult.totalPageNum(0, new ArrayList<>());
|
||||||
// }
|
}
|
||||||
Page<? extends BaseExcel> data=new PageImpl<>(Collections.emptyList());
|
Page<? extends BaseExcel> data=new PageImpl<>(Collections.emptyList());
|
||||||
//申请单查询
|
//申请单查询
|
||||||
if (!dto.getActualOrderNo().isEmpty()){
|
if (!dto.getActualOrderNo().isEmpty()){
|
||||||
|
|
|
@ -98,18 +98,18 @@ public class ManageServiceImpl implements ManageService {
|
||||||
@Override
|
@Override
|
||||||
public PageResult<OrderExceedStandardExcel> standardQuery(StandardQuery dto) {
|
public PageResult<OrderExceedStandardExcel> standardQuery(StandardQuery dto) {
|
||||||
//数据权限
|
//数据权限
|
||||||
// List<String> orderNos=baseUtil.getOrderNos();
|
List<String> orderNos=baseUtil.getOrderNos();
|
||||||
// if (orderNos==null||orderNos.isEmpty()) {
|
if (orderNos==null||orderNos.isEmpty()) {
|
||||||
// return PageResult.totalPageNum(0, new ArrayList<>());
|
return PageResult.totalPageNum(0, new ArrayList<>());
|
||||||
// }
|
}
|
||||||
|
|
||||||
PageRequest pageRequest = PageRequest
|
PageRequest pageRequest = PageRequest
|
||||||
.of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id").descending());
|
.of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id").descending());
|
||||||
Page<OrderExceedStandard> page=jdbcOrderExceedStandardRepository.findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContains(dto.getApplicant(),
|
Page<OrderExceedStandard> page=jdbcOrderExceedStandardRepository.findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContainsAndOrderNoIn(dto.getApplicant(),
|
||||||
dto.getCompanyName(),
|
dto.getCompanyName(),
|
||||||
dto.getActualOrderNo(),
|
dto.getActualOrderNo(),
|
||||||
dto.getOrderNo(),
|
dto.getOrderNo(),
|
||||||
// orderNos,
|
orderNos,
|
||||||
pageRequest);
|
pageRequest);
|
||||||
List<OrderExceedStandardExcel> excelList = getOrderExceedStandardExcels(page);
|
List<OrderExceedStandardExcel> excelList = getOrderExceedStandardExcels(page);
|
||||||
return PageResult.totalPageNum(page.getTotalElements(), excelList);
|
return PageResult.totalPageNum(page.getTotalElements(), excelList);
|
||||||
|
@ -127,11 +127,11 @@ public class ManageServiceImpl implements ManageService {
|
||||||
@Override
|
@Override
|
||||||
public PageResult<ItineraryPageDto> itineraryPageQuery(ItineraryPageQuery dto) {
|
public PageResult<ItineraryPageDto> itineraryPageQuery(ItineraryPageQuery dto) {
|
||||||
//数据权限
|
//数据权限
|
||||||
// List<Long> routeIds=baseUtil.getRouteIds();
|
List<Long> routeIds=baseUtil.getRouteIds();
|
||||||
// if (routeIds==null||routeIds.isEmpty()) {
|
if (routeIds==null||routeIds.isEmpty()) {
|
||||||
// return PageResult.totalPageNum(0, new ArrayList<>());
|
return PageResult.totalPageNum(0, new ArrayList<>());
|
||||||
// }
|
}
|
||||||
// dto.setRouteIds(routeIds);
|
dto.setRouteIds(routeIds);
|
||||||
|
|
||||||
List<User> users=new ArrayList<>();
|
List<User> users=new ArrayList<>();
|
||||||
if (!dto.getApplicant().isEmpty()){
|
if (!dto.getApplicant().isEmpty()){
|
||||||
|
@ -163,9 +163,7 @@ public class ManageServiceImpl implements ManageService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addOrderDownloadRecord(OrderDownloadRecord orderDownloadRecord) {
|
public void addOrderDownloadRecord(OrderDownloadRecord orderDownloadRecord) {
|
||||||
// User user= BaseContext.getCurrentUser();
|
User user= BaseContext.getCurrentUser();
|
||||||
User user=new User();
|
|
||||||
user.setEmployeeNo("123");
|
|
||||||
orderDownloadRecord.setEmployeeNo(user.getEmployeeNo());
|
orderDownloadRecord.setEmployeeNo(user.getEmployeeNo());
|
||||||
jdbcOrderDownloadRecordRepository.save(orderDownloadRecord);
|
jdbcOrderDownloadRecordRepository.save(orderDownloadRecord);
|
||||||
}
|
}
|
||||||
|
@ -179,11 +177,11 @@ public class ManageServiceImpl implements ManageService {
|
||||||
@Override
|
@Override
|
||||||
public PageResult<OrderPageExcel> orderPageQuery(OrderPageQuery dto) {
|
public PageResult<OrderPageExcel> orderPageQuery(OrderPageQuery dto) {
|
||||||
//数据权限
|
//数据权限
|
||||||
// List<Long> dataRouteIds=baseUtil.getRouteIds();
|
List<Long> dataRouteIds=baseUtil.getRouteIds();
|
||||||
// if (dataRouteIds==null||dataRouteIds.isEmpty()) {
|
if (dataRouteIds==null||dataRouteIds.isEmpty()) {
|
||||||
// return PageResult.totalPageNum(0, new ArrayList<>());
|
return PageResult.totalPageNum(0, new ArrayList<>());
|
||||||
// }
|
}
|
||||||
// dto.setRouteIds(dataRouteIds);
|
dto.setRouteIds(dataRouteIds);
|
||||||
|
|
||||||
//预订人
|
//预订人
|
||||||
if (!dto.getApplicant().equals("")){
|
if (!dto.getApplicant().equals("")){
|
||||||
|
|
|
@ -28,8 +28,7 @@ public class BaseUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Long> getRouteIds(){
|
public List<Long> getRouteIds(){
|
||||||
List<String> list = BaseContext.getCurrentUser().loadRoleOrg().getRoleOrgList()
|
List<String> list = BaseContext.getCurrentUser().loadRoleOrg().getRoleOrgCodeList();
|
||||||
.stream().filter(s->s.getOrgShortCode()!=null).map(SystemOrganizationVO::getOrgShortCode).toList();
|
|
||||||
List<RouteOrderExtensionFieldBasic> result= jdbcRouteOrderExtensionFieldBasicRepository.findAllByBelongDeptCodeIn(list);
|
List<RouteOrderExtensionFieldBasic> result= jdbcRouteOrderExtensionFieldBasicRepository.findAllByBelongDeptCodeIn(list);
|
||||||
return result.stream().map(RouteOrderExtensionFieldBasic::getRouteId).toList();
|
return result.stream().map(RouteOrderExtensionFieldBasic::getRouteId).toList();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue