数据范围以及角色员工

This commit is contained in:
yandanyang 2021-10-26 18:12:20 +08:00
parent 833082a918
commit 11850a4dd8
2 changed files with 10 additions and 4 deletions

View File

@ -72,6 +72,7 @@ public class DataScopeSqlConfigService {
configDTO.setWhereIndex(dataScopeAnnotation.whereIndex());
configDTO.setDataScopeWhereInType(dataScopeAnnotation.whereInType());
configDTO.setParamName(dataScopeAnnotation.paramName());
configDTO.setJoinSqlImplClazz(dataScopeAnnotation.joinSqlImplClazz());
dataScopeMethodMap.put(method.getDeclaringClass().getSimpleName() + "." + method.getName(), configDTO);
}
}

View File

@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@ -58,10 +59,14 @@ public class RoleEmployeeService {
public ResponseDTO<PageResultDTO<EmployeeVO>> listEmployeeByName(RoleQueryForm queryDTO) {
Page page = SmartPageUtil.convert2PageQuery(queryDTO);
List<EmployeeDTO> employeeDTOS = roleEmployeeDao.selectEmployeeByNamePage(page, queryDTO);
employeeDTOS.stream().filter(e -> e.getDepartmentId() != null).forEach(employeeDTO -> {
DepartmentEntity departmentEntity = departmentDao.selectById(employeeDTO.getDepartmentId());
employeeDTO.setDepartmentName(departmentEntity.getName());
});
List<Long> departmentIdList = employeeDTOS.stream().filter(e -> e.getDepartmentId() != null).map(EmployeeDTO::getDepartmentId).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(departmentIdList)){
List<DepartmentEntity> departmentEntities = departmentDao.selectBatchIds(departmentIdList);
Map<Long, String> departmentIdNameMap = departmentEntities.stream().collect(Collectors.toMap(DepartmentEntity::getId, DepartmentEntity::getName));
employeeDTOS.forEach(e->{
e.setDepartmentName(departmentIdNameMap.getOrDefault(e.getDepartmentId(), ""));
});
}
PageResultDTO<EmployeeVO> pageResultDTO = SmartPageUtil.convert2PageResult(page, employeeDTOS, EmployeeVO.class);
return ResponseDTO.ok(pageResultDTO);
}