岗位搜索功能bug修复

This commit is contained in:
冯辉
2026-06-26 23:54:59 +08:00
parent 8449bd5e71
commit 7dd3b96b92
6 changed files with 75 additions and 8 deletions

View File

@@ -82,6 +82,9 @@ public class ESJobDocument
@ApiModelProperty("是否火") @ApiModelProperty("是否火")
private Integer isHot; private Integer isHot;
@ApiModelProperty("是否急聘")
private Integer isUrgent;
@ApiModelProperty("申请次数") @ApiModelProperty("申请次数")
private Integer applyNum; private Integer applyNum;

View File

@@ -103,6 +103,9 @@ public class Job extends BaseEntity
@ApiModelProperty("是否火") @ApiModelProperty("是否火")
private Integer isHot; private Integer isHot;
@ApiModelProperty("是否急聘 0否 1是")
private Integer isUrgent;
@ApiModelProperty("申请次数") @ApiModelProperty("申请次数")
@JsonIgnore @JsonIgnore
private Integer applyNum; private Integer applyNum;

View File

@@ -346,6 +346,13 @@ public class ESJobSearchImpl implements IESJobSearchService
if(!StringUtil.isEmptyOrNull(appUser.getSalaryMin())){ if(!StringUtil.isEmptyOrNull(appUser.getSalaryMin())){
newSearch.setMinSalary(Long.valueOf(appUser.getSalaryMin())); newSearch.setMinSalary(Long.valueOf(appUser.getSalaryMin()));
} }
// 请求参数覆盖用户资料中的薪资偏好
if(Objects.nonNull(esJobSearch.getSalaryMin()) || Objects.nonNull(esJobSearch.getMinSalary())){
newSearch.setMinSalary(Objects.nonNull(esJobSearch.getSalaryMin()) ? esJobSearch.getSalaryMin() : esJobSearch.getMinSalary());
}
if(Objects.nonNull(esJobSearch.getSalaryMax()) || Objects.nonNull(esJobSearch.getMaxSalary())){
newSearch.setMaxSalary(Objects.nonNull(esJobSearch.getSalaryMax()) ? esJobSearch.getSalaryMax() : esJobSearch.getMaxSalary());
}
if(!StringUtil.isEmptyOrNull(esJobSearch.getJobType())){ if(!StringUtil.isEmptyOrNull(esJobSearch.getJobType())){
newSearch.setJobType(esJobSearch.getJobType()); newSearch.setJobType(esJobSearch.getJobType());
} }
@@ -891,8 +898,16 @@ public class ESJobSearchImpl implements IESJobSearchService
ESJobSearch newSearch = new ESJobSearch(); ESJobSearch newSearch = new ESJobSearch();
BeanUtils.copyProperties(esJobSearch,newSearch); BeanUtils.copyProperties(esJobSearch,newSearch);
//查询
if(appUser!=null){ // 判断是否为用户主动搜索(有明确的搜索条件),而非纯推荐场景
boolean isExplicitSearch = !StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())
|| !StringUtil.isEmptyOrNull(esJobSearch.getJobCategory())
|| !StringUtil.isEmptyOrNull(esJobSearch.getCompanyName())
|| !StringUtil.isEmptyOrNull(esJobSearch.getDescription());
// 用户资料偏好仅在"纯推荐"场景下作为个性化过滤条件;
// 用户主动搜索时不应被资料中的薪资/学历/经验/区域等偏好缩小结果范围
if(appUser != null && !isExplicitSearch){
if(!ListUtil.isEmptyOrNull(appUser.getJobTitle())){ if(!ListUtil.isEmptyOrNull(appUser.getJobTitle())){
List<String> jobTitle = appUser.getJobTitle(); List<String> jobTitle = appUser.getJobTitle();
newSearch.setJobTitle(String.join(",", jobTitle)); newSearch.setJobTitle(String.join(",", jobTitle));
@@ -906,9 +921,6 @@ public class ESJobSearchImpl implements IESJobSearchService
if(!StringUtil.isEmptyOrNull(appUser.getWorkExperience())){ if(!StringUtil.isEmptyOrNull(appUser.getWorkExperience())){
newSearch.setExperience(appUser.getWorkExperience()); newSearch.setExperience(appUser.getWorkExperience());
} }
if(!StringUtil.isEmptyOrNull(esJobSearch.getExperience())){
newSearch.setExperience(esJobSearch.getExperience());
}
if(!StringUtil.isEmptyOrNull(appUser.getSalaryMax())){ if(!StringUtil.isEmptyOrNull(appUser.getSalaryMax())){
newSearch.setMaxSalary(Long.valueOf(appUser.getSalaryMax())); newSearch.setMaxSalary(Long.valueOf(appUser.getSalaryMax()));
} }
@@ -917,12 +929,22 @@ public class ESJobSearchImpl implements IESJobSearchService
} }
} }
// 请求参数始终优先于用户资料偏好
if(Objects.nonNull(esJobSearch.getSalaryMin()) || Objects.nonNull(esJobSearch.getMinSalary())){
newSearch.setMinSalary(Objects.nonNull(esJobSearch.getSalaryMin()) ? esJobSearch.getSalaryMin() : esJobSearch.getMinSalary());
}
if(Objects.nonNull(esJobSearch.getSalaryMax()) || Objects.nonNull(esJobSearch.getMaxSalary())){
newSearch.setMaxSalary(Objects.nonNull(esJobSearch.getSalaryMax()) ? esJobSearch.getSalaryMax() : esJobSearch.getMaxSalary());
}
if(!StringUtil.isEmptyOrNull(esJobSearch.getArea())){ if(!StringUtil.isEmptyOrNull(esJobSearch.getArea())){
newSearch.setArea(esJobSearch.getArea()); newSearch.setArea(esJobSearch.getArea());
} }
if(!StringUtil.isEmptyOrNull(esJobSearch.getEducation())){ if(!StringUtil.isEmptyOrNull(esJobSearch.getEducation())){
newSearch.setEducation(esJobSearch.getEducation()); newSearch.setEducation(esJobSearch.getEducation());
} }
if(!StringUtil.isEmptyOrNull(esJobSearch.getExperience())){
newSearch.setExperience(esJobSearch.getExperience());
}
if(!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){ if(!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){
newSearch.setJobTitle(esJobSearch.getJobTitle()); newSearch.setJobTitle(esJobSearch.getJobTitle());
} }

View File

@@ -34,15 +34,20 @@ import org.dromara.easyes.core.biz.EsPageInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.sql.DataSource;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.sql.Connection;
import java.sql.Statement;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
@@ -96,6 +101,34 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
@Autowired @Autowired
private NoticeMapper noticeMapper; private NoticeMapper noticeMapper;
@Autowired
private DataSource dataSource;
/**
* 应用启动后自动迁移:添加 is_urgent 列(幂等)
*/
@EventListener(ApplicationReadyEvent.class)
public void migrateIsUrgentColumn() {
try (Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement()) {
String checkSql = "SELECT COUNT(*) FROM information_schema.columns WHERE table_name='job' AND column_name='is_urgent'";
java.sql.ResultSet rs = stmt.executeQuery(checkSql);
boolean exists = false;
if (rs.next()) {
exists = rs.getInt(1) > 0;
}
rs.close();
if (!exists) {
stmt.execute("ALTER TABLE job ADD COLUMN is_urgent CHAR(1) DEFAULT '0'");
logger.info("急聘功能迁移: 成功添加 job.is_urgent 列");
} else {
logger.info("急聘功能迁移: job.is_urgent 列已存在,跳过");
}
} catch (Exception e) {
logger.error("急聘功能迁移失败: {}", e.getMessage());
}
}
/** /**
* 更新工作地址的经纬度信息 * 更新工作地址的经纬度信息
*/ */

View File

@@ -26,6 +26,7 @@
<result property="view" column="view" /> <result property="view" column="view" />
<result property="companyId" column="company_id" /> <result property="companyId" column="company_id" />
<result property="isHot" column="is_hot" /> <result property="isHot" column="is_hot" />
<result property="isUrgent" column="is_urgent" />
<result property="dataSource" column="data_source" /> <result property="dataSource" column="data_source" />
<result property="jobUrl" column="job_url" /> <result property="jobUrl" column="job_url" />
<result property="rowId" column="row_id" /> <result property="rowId" column="row_id" />
@@ -61,6 +62,7 @@
<result property="view" column="view" /> <result property="view" column="view" />
<result property="companyId" column="company_id" /> <result property="companyId" column="company_id" />
<result property="isHot" column="is_hot" /> <result property="isHot" column="is_hot" />
<result property="isUrgent" column="is_urgent" />
<result property="applyNum" column="apply_num" /> <result property="applyNum" column="apply_num" />
<result property="dataSource" column="data_source" /> <result property="dataSource" column="data_source" />
<result property="jobLocationAreaCode" column="job_location_area_code" /> <result property="jobLocationAreaCode" column="job_location_area_code" />
@@ -99,7 +101,7 @@
</resultMap> </resultMap>
<sql id="selectJobVo"> <sql id="selectJobVo">
select job_id, job_title, min_salary, max_salary, education, experience, company_name, job_location, posting_date, vacancies, del_flag, create_by, create_time, update_by, update_time, remark, latitude, longitude, "view", company_id , is_hot ,apply_num,is_publish, description,job_location_area_code,data_source,job_url,job_category,is_explain,explain_url,cover,job_type,job_address, review_status from job select job_id, job_title, min_salary, max_salary, education, experience, company_name, job_location, posting_date, vacancies, del_flag, create_by, create_time, update_by, update_time, remark, latitude, longitude, "view", company_id , is_hot ,is_urgent,apply_num,is_publish, description,job_location_area_code,data_source,job_url,job_category,is_explain,explain_url,cover,job_type,job_address, review_status from job
</sql> </sql>
<insert id="insertBatchRowWork"> <insert id="insertBatchRowWork">
INSERT INTO row_work ( INSERT INTO row_work (
@@ -128,7 +130,7 @@
INSERT INTO job ( INSERT INTO job (
job_title, min_salary, max_salary, education, experience, company_name, job_location, job_title, min_salary, max_salary, education, experience, company_name, job_location,
job_location_area_code, posting_date, vacancies, latitude, longitude, "view", company_id, job_location_area_code, posting_date, vacancies, latitude, longitude, "view", company_id,
is_hot, apply_num, description, is_publish, data_source, job_url, remark, del_flag, is_hot, is_urgent, apply_num, description, is_publish, data_source, job_url, remark, del_flag,
create_by, create_time, row_id, job_category,job_type,job_address create_by, create_time, row_id, job_category,job_type,job_address
) VALUES ) VALUES
<foreach collection="list" item="job" separator=","> <foreach collection="list" item="job" separator=",">
@@ -136,7 +138,7 @@
#{job.jobTitle}, #{job.minSalary}, #{job.maxSalary}, #{job.education}, #{job.experience}, #{job.jobTitle}, #{job.minSalary}, #{job.maxSalary}, #{job.education}, #{job.experience},
#{job.companyName}, #{job.jobLocation}, #{job.jobLocationAreaCode}, #{job.postingDate}, #{job.companyName}, #{job.jobLocation}, #{job.jobLocationAreaCode}, #{job.postingDate},
#{job.vacancies}, #{job.latitude}, #{job.longitude}, #{job.view}, #{job.companyId}, #{job.vacancies}, #{job.latitude}, #{job.longitude}, #{job.view}, #{job.companyId},
#{job.isHot}, #{job.applyNum}, #{job.description}, #{job.isPublish}, #{job.dataSource}, #{job.isHot}, #{job.isUrgent}, #{job.applyNum}, #{job.description}, #{job.isPublish}, #{job.dataSource},
#{job.jobUrl}, #{job.remark}, #{job.delFlag}, #{job.createBy}, #{job.createTime}, #{job.jobUrl}, #{job.remark}, #{job.delFlag}, #{job.createBy}, #{job.createTime},
#{job.rowId}, #{job.jobCategory},#{job.jobType},#{job.jobAddress} #{job.rowId}, #{job.jobCategory},#{job.jobType},#{job.jobAddress}
) )

View File

@@ -0,0 +1,4 @@
-- 急聘功能:给 job 表添加 is_urgent 字段
-- 0 = 非急聘默认1 = 急聘
ALTER TABLE "ks_db3"."job" ADD COLUMN "is_urgent" CHAR(1) DEFAULT '0';
COMMENT ON COLUMN "ks_db3"."job"."is_urgent" IS '是否急聘 0否 1是';