岗位搜索功能bug修复
This commit is contained in:
@@ -82,6 +82,9 @@ public class ESJobDocument
|
||||
@ApiModelProperty("是否火")
|
||||
private Integer isHot;
|
||||
|
||||
@ApiModelProperty("是否急聘")
|
||||
private Integer isUrgent;
|
||||
|
||||
@ApiModelProperty("申请次数")
|
||||
private Integer applyNum;
|
||||
|
||||
|
||||
@@ -103,6 +103,9 @@ public class Job extends BaseEntity
|
||||
@ApiModelProperty("是否火")
|
||||
private Integer isHot;
|
||||
|
||||
@ApiModelProperty("是否急聘 0否 1是")
|
||||
private Integer isUrgent;
|
||||
|
||||
@ApiModelProperty("申请次数")
|
||||
@JsonIgnore
|
||||
private Integer applyNum;
|
||||
|
||||
@@ -346,6 +346,13 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
if(!StringUtil.isEmptyOrNull(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())){
|
||||
newSearch.setJobType(esJobSearch.getJobType());
|
||||
}
|
||||
@@ -891,8 +898,16 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
|
||||
ESJobSearch newSearch = new ESJobSearch();
|
||||
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())){
|
||||
List<String> jobTitle = appUser.getJobTitle();
|
||||
newSearch.setJobTitle(String.join(",", jobTitle));
|
||||
@@ -906,9 +921,6 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
if(!StringUtil.isEmptyOrNull(appUser.getWorkExperience())){
|
||||
newSearch.setExperience(appUser.getWorkExperience());
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getExperience())){
|
||||
newSearch.setExperience(esJobSearch.getExperience());
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(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())){
|
||||
newSearch.setArea(esJobSearch.getArea());
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getEducation())){
|
||||
newSearch.setEducation(esJobSearch.getEducation());
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getExperience())){
|
||||
newSearch.setExperience(esJobSearch.getExperience());
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){
|
||||
newSearch.setJobTitle(esJobSearch.getJobTitle());
|
||||
}
|
||||
|
||||
@@ -34,15 +34,20 @@ import org.dromara.easyes.core.biz.EsPageInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Statement;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
@@ -96,6 +101,34 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
@Autowired
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新工作地址的经纬度信息
|
||||
*/
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
<result property="view" column="view" />
|
||||
<result property="companyId" column="company_id" />
|
||||
<result property="isHot" column="is_hot" />
|
||||
<result property="isUrgent" column="is_urgent" />
|
||||
<result property="dataSource" column="data_source" />
|
||||
<result property="jobUrl" column="job_url" />
|
||||
<result property="rowId" column="row_id" />
|
||||
@@ -61,6 +62,7 @@
|
||||
<result property="view" column="view" />
|
||||
<result property="companyId" column="company_id" />
|
||||
<result property="isHot" column="is_hot" />
|
||||
<result property="isUrgent" column="is_urgent" />
|
||||
<result property="applyNum" column="apply_num" />
|
||||
<result property="dataSource" column="data_source" />
|
||||
<result property="jobLocationAreaCode" column="job_location_area_code" />
|
||||
@@ -99,7 +101,7 @@
|
||||
</resultMap>
|
||||
|
||||
<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>
|
||||
<insert id="insertBatchRowWork">
|
||||
INSERT INTO row_work (
|
||||
@@ -128,7 +130,7 @@
|
||||
INSERT INTO job (
|
||||
job_title, min_salary, max_salary, education, experience, company_name, job_location,
|
||||
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
|
||||
) VALUES
|
||||
<foreach collection="list" item="job" separator=",">
|
||||
@@ -136,7 +138,7 @@
|
||||
#{job.jobTitle}, #{job.minSalary}, #{job.maxSalary}, #{job.education}, #{job.experience},
|
||||
#{job.companyName}, #{job.jobLocation}, #{job.jobLocationAreaCode}, #{job.postingDate},
|
||||
#{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.rowId}, #{job.jobCategory},#{job.jobType},#{job.jobAddress}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user