diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ESJobSearchImpl.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ESJobSearchImpl.java index 92b81c2..65eadbd 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ESJobSearchImpl.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ESJobSearchImpl.java @@ -15,7 +15,9 @@ import com.ruoyi.cms.util.StringUtil; import com.ruoyi.common.core.domain.entity.Company; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SiteSecurityUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.bean.BeanUtils; import org.dromara.easyes.core.biz.EsPageInfo; import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper; @@ -202,6 +204,10 @@ public class ESJobSearchImpl implements IESJobSearchService if(StringUtil.isEmptyOrNull(job.getCompanyNature())){ esJobDocument.setCompanyNature("6"); } + if (StringUtils.isNotEmpty(job.getPostingDate())) { + Date date = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,job.getPostingDate()); + esJobDocument.setPostingDate(date); + } esJobDocumentList.add(esJobDocument); } @@ -554,15 +560,16 @@ public class ESJobSearchImpl implements IESJobSearchService wrapper.and(x->x.like(ESJobDocument::getJobLocation,esJobSearch.getJobLocation())); } if(Objects.nonNull(esJobSearch.getOrder())){ + wrapper.orderByDesc(ESJobDocument::getPostingDate); if(esJobSearch.getOrder()==1){ wrapper.orderByDesc(ESJobDocument::getIsHot); } - if(esJobSearch.getOrder()==2){ - wrapper.orderByDesc(ESJobDocument::getPostingDate); - } if(esJobSearch.getOrder()==3){ wrapper.orderByDesc(ESJobDocument::getMaxSalary); } + }else{ + //默认按照发布时间倒叙 + wrapper.orderByDesc(ESJobDocument::getPostingDate); } //企业用户排除es去除jobIds boolean isCompanyUser = StringUtil.IS_COMPANY_USER.equals(esJobSearch.getUserType()); @@ -631,14 +638,15 @@ public class ESJobSearchImpl implements IESJobSearchService wrapper.and(a->a.eq(ESJobDocument::getType,jobQuery.getType().trim())); } if(Objects.nonNull(jobQuery.getOrder())){ - if (jobQuery.getOrder()==2){ - wrapper.orderByDesc(ESJobDocument::getPostingDate); - } + wrapper.orderByDesc(ESJobDocument::getPostingDate); if (jobQuery.getOrder()==1){ wrapper.orderByDesc(ESJobDocument::getIsHot); wrapper.orderByDesc(ESJobDocument::getApplyNum); wrapper.orderByDesc(ESJobDocument::getView); } + }else{ + //默认按照发布时间倒叙 + wrapper.orderByDesc(ESJobDocument::getPostingDate); } EsPageInfo esJobDocumentEsPageInfo = esJobDocumentMapper.pageQuery(wrapper, pageNum, pageSize); return esJobDocumentEsPageInfo;