This commit is contained in:
张成
2026-04-08 16:39:27 +08:00
parent 048c40d802
commit f2a8e61016
8 changed files with 597 additions and 66 deletions

View File

@@ -32,15 +32,16 @@ class JobFilterService {
}
/**
* 根据职位类型ID获取技能关键词排除关键词
* 根据职位类型ID获取技能关键词排除关键词、标题须含词
* @param {number} jobTypeId - 职位类型ID
* @returns {Promise<{commonSkills: Array, excludeKeywords: Array}>}
* @returns {Promise<{commonSkills: Array, excludeKeywords: Array, titleIncludeKeywords: Array}>}
*/
async getJobTypeConfig(jobTypeId) {
if (!jobTypeId) {
return {
commonSkills: this.defaultCommonSkills,
excludeKeywords: this.defaultExcludeKeywords
excludeKeywords: this.defaultExcludeKeywords,
titleIncludeKeywords: []
};
}
@@ -55,7 +56,8 @@ class JobFilterService {
console.warn('[职位过滤服务] job_types 模型不存在,使用默认配置');
return {
commonSkills: this.defaultCommonSkills,
excludeKeywords: this.defaultExcludeKeywords
excludeKeywords: this.defaultExcludeKeywords,
titleIncludeKeywords: []
};
}
@@ -67,7 +69,8 @@ class JobFilterService {
console.warn(`[职位过滤服务] 职位类型 ${jobTypeId} 不存在或已禁用,使用默认配置`);
return {
commonSkills: this.defaultCommonSkills,
excludeKeywords: this.defaultExcludeKeywords
excludeKeywords: this.defaultExcludeKeywords,
titleIncludeKeywords: []
};
}
@@ -76,6 +79,7 @@ class JobFilterService {
// 解析 JSON 字段
let commonSkills = this.defaultCommonSkills;
let excludeKeywords = this.defaultExcludeKeywords;
let titleIncludeKeywords = [];
if (jobTypeData.commonSkills) {
try {
@@ -103,9 +107,23 @@ class JobFilterService {
}
}
if (jobTypeData.titleIncludeKeywords) {
try {
const parsed = typeof jobTypeData.titleIncludeKeywords === 'string'
? JSON.parse(jobTypeData.titleIncludeKeywords)
: jobTypeData.titleIncludeKeywords;
if (Array.isArray(parsed)) {
titleIncludeKeywords = parsed.map((k) => String(k || '').trim()).filter(Boolean);
}
} catch (e) {
console.warn(`[职位过滤服务] 解析 titleIncludeKeywords 失败:`, e);
}
}
const config = {
commonSkills,
excludeKeywords
excludeKeywords,
titleIncludeKeywords
};
// 缓存配置缓存5分钟
@@ -119,7 +137,8 @@ class JobFilterService {
console.error(`[职位过滤服务] 获取职位类型配置失败:`, error);
return {
commonSkills: this.defaultCommonSkills,
excludeKeywords: this.defaultExcludeKeywords
excludeKeywords: this.defaultExcludeKeywords,
titleIncludeKeywords: []
};
}
}