app/job/list修改查询条件排序条件

This commit is contained in:
chenshaohua
2026-07-08 11:39:37 +08:00
parent 9f81dbac50
commit 3db8786e89

View File

@@ -618,18 +618,25 @@ public class ESJobSearchImpl implements IESJobSearchService
// 先开启打分、优先按匹配分数排序(关键词前台命中越高越靠前)
wrapper.trackScores();
wrapper.sortByScore(SortOrder.DESC);
if(Objects.nonNull(esJobSearch.getOrder())){
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
if(esJobSearch.getOrder()==1){
wrapper.orderByDesc(ESJobDocument::getIsHot);
switch (esJobSearch.getOrder()) {
case 0: // 推荐:权重 → 最新发布
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
break;
case 1: // 最热:权重 → 热度
wrapper.orderByDesc(ESJobDocument::getIsHot);
wrapper.orderByDesc(ESJobDocument::getApplyNum);
wrapper.orderByDesc(ESJobDocument::getView);
break;
case 2: // 最新发布:权重 → 最新发布
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
break;
case 3: // 最大薪资:权重 → 最高薪资
wrapper.orderByDesc(ESJobDocument::getMaxSalary);
break;
default: // 默认:权重 → 最新发布
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
}
if(esJobSearch.getOrder()==3){
wrapper.orderByDesc(ESJobDocument::getMaxSalary);
}
}else{
//默认按照发布时间倒叙
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
}
//企业用户排除es去除jobIds
boolean isCompanyUser = StringUtil.IS_COMPANY_USER.equals(esJobSearch.getUserType());