|
|
@@ -257,23 +257,53 @@ public class ResumesServiceImpl extends ServiceImpl<ResumesDao, Resumes> impleme
|
|
|
}
|
|
|
@Override
|
|
|
public Result selectResumesListHr(Integer page, Integer limit, ResumesListDto resumesDto) {
|
|
|
- Page<ResumesListDto> resumesPage;
|
|
|
- if (page != null && limit != null) {
|
|
|
- resumesPage = new Page<>(page, limit);
|
|
|
- } else {
|
|
|
- resumesPage = new Page<>();
|
|
|
- resumesPage.setSize(-1);
|
|
|
+ // 1. 确保查询参数不为null(避免getMatch处理null对象)
|
|
|
+ if (resumesDto == null) {
|
|
|
+ resumesDto = new ResumesListDto();
|
|
|
}
|
|
|
+ // 处理匹配条件(假设getMatch可能修改resumesDto,提前执行)
|
|
|
getMatch(resumesDto);
|
|
|
- resumesPage.setRecords(baseMapper.selectResumesListHr(resumesDto));
|
|
|
- return Result.success().put("data",resumesPage);
|
|
|
-}
|
|
|
+
|
|
|
+ // 2. 规范分页参数(避免size=-1的潜在问题,统一分页默认值)
|
|
|
+ int currentPage = (page != null && page >= 1) ? page : 1;
|
|
|
+ int pageSize = (limit != null && limit >= 1) ? limit : Integer.MAX_VALUE; // 无limit时查全部
|
|
|
+ Page<ResumesListDto> resumesPage = new Page<>(currentPage, pageSize);
|
|
|
+
|
|
|
+ // 3. 查询数据(处理Mapper返回null的情况)
|
|
|
+ List<ResumesListDto> resumesListDtoList = baseMapper.selectResumesListHr(resumesDto);
|
|
|
+ // 若Mapper返回null,转为空列表(避免后续isEmpty()空指针)
|
|
|
+ if (resumesListDtoList == null) {
|
|
|
+ resumesListDtoList = new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 4. 处理分页逻辑(区分"分页查询"和"查全部")
|
|
|
+ if (pageSize != Integer.MAX_VALUE) { // 分页查询:计算总条数和当前页记录
|
|
|
+ int total = resumesListDtoList.size();
|
|
|
+ resumesPage.setTotal(total); // 设置总记录数
|
|
|
+ // 计算当前页的起始和结束索引(避免数组越界)
|
|
|
+ int startIndex = (currentPage - 1) * pageSize;
|
|
|
+ int endIndex = Math.min(startIndex + pageSize, total);
|
|
|
+ // 截取当前页记录(若startIndex >= total,返回空列表)
|
|
|
+ List<ResumesListDto> currentPageRecords = startIndex < total
|
|
|
+ ? resumesListDtoList.subList(startIndex, endIndex)
|
|
|
+ : new ArrayList<>();
|
|
|
+ resumesPage.setRecords(currentPageRecords);
|
|
|
+ } else { // 查全部:直接设置所有记录,总条数为列表大小
|
|
|
+ resumesPage.setRecords(resumesListDtoList);
|
|
|
+ resumesPage.setTotal(resumesListDtoList.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 5. 统一返回格式(无论有无数据,均返回Page对象,避免null)
|
|
|
+ return Result.success().put("data", resumesPage);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
private static Map<String, Integer> DEGREE_MIN_RANGE_MAP = Collections.emptyMap();
|
|
|
static {
|
|
|
Map<String, Integer> tempMap = new HashMap<>();
|
|
|
- tempMap.put("初中及以下", 0); // 最小范围(最低学历)
|
|
|
+ tempMap.put("初中以下", 0); // 最小范围(最低学历)
|
|
|
tempMap.put("高中", 1);
|
|
|
- tempMap.put("中专/中技", 2);
|
|
|
+ tempMap.put("中专/高中", 1);
|
|
|
tempMap.put("大专", 3);
|
|
|
tempMap.put("本科", 4);
|
|
|
tempMap.put("硕士", 5);
|
|
|
@@ -286,13 +316,13 @@ public class ResumesServiceImpl extends ServiceImpl<ResumesDao, Resumes> impleme
|
|
|
static {
|
|
|
Map<String, int[]> tempMap = new HashMap<>();
|
|
|
// 注意:数组第一个元素是minSalary,第二个是maxSalary
|
|
|
- tempMap.put("3K以下", new int[]{0, 3000}); // 0 ≤ 薪资 < 3000
|
|
|
- tempMap.put("3-5K", new int[]{3000, 5000}); // 3000 ≤ 薪资 < 5000
|
|
|
- tempMap.put("5-10K", new int[]{5000, 10000}); // 5000 ≤ 薪资 < 10000
|
|
|
- tempMap.put("10-20K", new int[]{10000, 20000}); // 10000 ≤ 薪资 < 20000
|
|
|
- tempMap.put("20-50K", new int[]{20000, 50000}); // 20000 ≤ 薪资 < 50000
|
|
|
- tempMap.put("50-100K", new int[]{50000, 100000}); // 50000 ≤ 薪资 < 100000
|
|
|
- tempMap.put("100K以上", new int[]{100000, Integer.MAX_VALUE}); // 薪资 ≥ 100000(无上限)
|
|
|
+ tempMap.put("2—4K", new int[]{2000, 4000}); // 0 ≤ 薪资 < 3000
|
|
|
+ tempMap.put("4—6K", new int[]{4000, 6000}); // 3000 ≤ 薪资 < 5000
|
|
|
+ tempMap.put("6—8K", new int[]{6000, 8000}); // 5000 ≤ 薪资 < 10000
|
|
|
+ tempMap.put("8—10K", new int[]{8000, 10000}); // 10000 ≤ 薪资 < 20000
|
|
|
+ tempMap.put("10—12K", new int[]{10000, 12000}); // 20000 ≤ 薪资 < 50000
|
|
|
+// tempMap.put("12k以上", new int[]{50000, 100000}); // 50000 ≤ 薪资 < 100000
|
|
|
+// tempMap.put("100K以上", new int[]{100000, Integer.MAX_VALUE}); // 薪资 ≥ 100000(无上限)
|
|
|
// 包装为不可修改的Map,防止外部篡改
|
|
|
SALARY_RANGE_MAP = Collections.unmodifiableMap(tempMap);
|
|
|
}
|
|
|
@@ -306,24 +336,24 @@ public class ResumesServiceImpl extends ServiceImpl<ResumesDao, Resumes> impleme
|
|
|
tempMap.put("1年以内", new int[]{0, 1}); // 0 ≤ 工作经验 < 1年
|
|
|
tempMap.put("1-3年", new int[]{1, 3}); // 1 ≤ 工作经验 < 3年
|
|
|
tempMap.put("3-5年", new int[]{3, 5}); // 3 ≤ 工作经验 < 5年
|
|
|
- tempMap.put("5-10年", new int[]{5, 10}); // 5 ≤ 工作经验 < 10年
|
|
|
- tempMap.put("10年以上", new int[]{10, Integer.MAX_VALUE}); // 工作经验 ≥ 10年(无上限)
|
|
|
- tempMap.put("应届生", new int[]{0, 0}); // 0年经验(无工作经验)
|
|
|
+ tempMap.put("5-8年", new int[]{5, 8}); // 5 ≤ 工作经验 < 10年
|
|
|
+ tempMap.put("8年以上", new int[]{8, Integer.MAX_VALUE}); // 工作经验 ≥ 10年(无上限)
|
|
|
+ tempMap.put("无经验", new int[]{0, 0}); // 0年经验(无工作经验)
|
|
|
tempMap.put("在校生", new int[]{0, 0}); // 0年经验(无工作经验)
|
|
|
|
|
|
// 包装为不可修改的Map,防止外部篡改
|
|
|
WORK_EXPERIENCE_RANGE_MAP = Collections.unmodifiableMap(tempMap);
|
|
|
}
|
|
|
private ResumesListDto getMatch(ResumesListDto resumesListDto){
|
|
|
- if (resumesListDto.getDegree()!=null){
|
|
|
+ if (resumesListDto.getEduRange()!=null&&!resumesListDto.getEduRange().isEmpty()){
|
|
|
resumesListDto.setDegree(String.valueOf(DEGREE_MIN_RANGE_MAP.get(resumesListDto.getEduRange())));
|
|
|
}
|
|
|
- if(resumesListDto.getSalaryRange()!=null){
|
|
|
+ if(resumesListDto.getSalaryRange()!=null && !resumesListDto.getSalaryRange().isEmpty()){
|
|
|
int[] range = SALARY_RANGE_MAP.get(resumesListDto.getSalaryRange());
|
|
|
resumesListDto.setMinSalary(range[0]);
|
|
|
resumesListDto.setMaxSalary(range[1]);
|
|
|
}
|
|
|
- if (resumesListDto.getExpRange()!=null){
|
|
|
+ if (resumesListDto.getExpRange()!=null&&!resumesListDto.getExpRange().isEmpty()){
|
|
|
int[] range = WORK_EXPERIENCE_RANGE_MAP.get(resumesListDto.getExpRange());
|
|
|
resumesListDto.setMinWorkExp(range[0]);
|
|
|
resumesListDto.setMaxWorkExp(range[1]);
|