1
This commit is contained in:
@@ -772,20 +772,57 @@ class JobManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析期望薪资
|
||||
* @param {string} expectedSalary - 期望薪资描述
|
||||
* @returns {number|null} 期望薪资数值(元)
|
||||
* 解析期望薪资(返回平均值)
|
||||
* @param {string} expectedSalary - 期望薪资描述(如 "20-30K"、"5000-6000元/月")
|
||||
* @returns {number|null} 期望薪资数值(元),如果是范围则返回平均值
|
||||
*/
|
||||
parse_expected_salary(expectedSalary) {
|
||||
if (!expectedSalary) return null;
|
||||
|
||||
// 匹配数字+K格式(如:20K)
|
||||
const match = expectedSalary.match(/(\d+)[kK千]/);
|
||||
if (match) {
|
||||
return parseInt(match[1]) * 1000;
|
||||
// 1. 匹配K格式范围:20-30K
|
||||
const kRangeMatch = expectedSalary.match(/(\d+)[-~](\d+)[kK千]/);
|
||||
if (kRangeMatch) {
|
||||
const min = parseInt(kRangeMatch[1]) * 1000;
|
||||
const max = parseInt(kRangeMatch[2]) * 1000;
|
||||
return (min + max) / 2; // 返回平均值
|
||||
}
|
||||
|
||||
// 匹配纯数字(如:20000)
|
||||
// 2. 匹配单个K值:25K
|
||||
const kMatch = expectedSalary.match(/(\d+)[kK千]/);
|
||||
if (kMatch) {
|
||||
return parseInt(kMatch[1]) * 1000;
|
||||
}
|
||||
|
||||
// 3. 匹配元/月格式范围:5000-6000元/月
|
||||
const yuanRangeMatch = expectedSalary.match(/(\d+)[-~](\d+)[元万]/);
|
||||
if (yuanRangeMatch) {
|
||||
const min = parseInt(yuanRangeMatch[1]);
|
||||
const max = parseInt(yuanRangeMatch[2]);
|
||||
if (expectedSalary.includes('万')) {
|
||||
return ((min + max) / 2) * 10000;
|
||||
} else {
|
||||
return (min + max) / 2; // 返回平均值
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 匹配单个元/月值:5000元/月
|
||||
const yuanMatch = expectedSalary.match(/(\d+)[元万]/);
|
||||
if (yuanMatch) {
|
||||
const value = parseInt(yuanMatch[1]);
|
||||
if (expectedSalary.includes('万')) {
|
||||
return value * 10000;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 匹配纯数字范围(如:20000-30000)
|
||||
const numRangeMatch = expectedSalary.match(/(\d+)[-~](\d+)/);
|
||||
if (numRangeMatch) {
|
||||
return (parseInt(numRangeMatch[1]) + parseInt(numRangeMatch[2])) / 2; // 返回平均值
|
||||
}
|
||||
|
||||
// 6. 匹配纯数字(如:20000)
|
||||
const numMatch = expectedSalary.match(/(\d+)/);
|
||||
if (numMatch) {
|
||||
return parseInt(numMatch[1]);
|
||||
@@ -834,28 +871,64 @@ class JobManager {
|
||||
|
||||
/**
|
||||
* 解析薪资范围
|
||||
* @param {string} salaryDesc - 薪资描述(如 "15-25K·14薪")
|
||||
* @returns {object} 薪资范围 { min, max }
|
||||
* @param {string} salaryDesc - 薪资描述(如 "15-25K·14薪"、"5000-6000元/月")
|
||||
* @returns {object} 薪资范围 { min, max },单位:元
|
||||
*/
|
||||
parse_salary_range(salaryDesc) {
|
||||
if (!salaryDesc) return { min: 0, max: 0 };
|
||||
|
||||
// 匹配常见格式:15-25K, 15K-25K, 15-25k·14薪
|
||||
const match = salaryDesc.match(/(\d+)[-~](\d+)[kK]/);
|
||||
if (match) {
|
||||
// 1. 匹配K格式:40-60K, 30-40K·18薪(忽略后面的薪数)
|
||||
const kMatch = salaryDesc.match(/(\d+)[-~](\d+)[kK千]/);
|
||||
if (kMatch) {
|
||||
return {
|
||||
min: parseInt(match[1]) * 1000,
|
||||
max: parseInt(match[2]) * 1000
|
||||
min: parseInt(kMatch[1]) * 1000,
|
||||
max: parseInt(kMatch[2]) * 1000
|
||||
};
|
||||
}
|
||||
|
||||
// 匹配单个数值:25K
|
||||
const singleMatch = salaryDesc.match(/(\d+)[kK]/);
|
||||
if (singleMatch) {
|
||||
const value = parseInt(singleMatch[1]) * 1000;
|
||||
// 2. 匹配单个K值:25K
|
||||
const singleKMatch = salaryDesc.match(/(\d+)[kK千]/);
|
||||
if (singleKMatch) {
|
||||
const value = parseInt(singleKMatch[1]) * 1000;
|
||||
return { min: value, max: value };
|
||||
}
|
||||
|
||||
// 3. 匹配元/月格式:5000-6000元/月
|
||||
const yuanMatch = salaryDesc.match(/(\d+)[-~](\d+)[元万]/);
|
||||
if (yuanMatch) {
|
||||
const min = parseInt(yuanMatch[1]);
|
||||
const max = parseInt(yuanMatch[2]);
|
||||
// 判断单位(万或元)
|
||||
if (salaryDesc.includes('万')) {
|
||||
return {
|
||||
min: min * 10000,
|
||||
max: max * 10000
|
||||
};
|
||||
} else {
|
||||
return { min, max };
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 匹配单个元/月值:5000元/月
|
||||
const singleYuanMatch = salaryDesc.match(/(\d+)[元万]/);
|
||||
if (singleYuanMatch) {
|
||||
const value = parseInt(singleYuanMatch[1]);
|
||||
if (salaryDesc.includes('万')) {
|
||||
return { min: value * 10000, max: value * 10000 };
|
||||
} else {
|
||||
return { min: value, max: value };
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 匹配纯数字格式(如:20000-30000)
|
||||
const numMatch = salaryDesc.match(/(\d+)[-~](\d+)/);
|
||||
if (numMatch) {
|
||||
return {
|
||||
min: parseInt(numMatch[1]),
|
||||
max: parseInt(numMatch[2])
|
||||
};
|
||||
}
|
||||
|
||||
return { min: 0, max: 0 };
|
||||
}
|
||||
|
||||
|
||||
@@ -472,46 +472,119 @@ class JobFilterService {
|
||||
|
||||
/**
|
||||
* 解析薪资范围
|
||||
* @param {string} salaryDesc - 薪资描述(如 "15-25K·14薪")
|
||||
* @returns {object|null} 薪资范围 { min, max }
|
||||
* @param {string} salaryDesc - 薪资描述(如 "15-25K·14薪"、"5000-6000元/月")
|
||||
* @returns {object|null} 薪资范围 { min, max },单位:元
|
||||
*/
|
||||
parseSalaryRange(salaryDesc) {
|
||||
if (!salaryDesc) return null;
|
||||
|
||||
// 匹配 "15-25K" 或 "15K-25K" 格式
|
||||
const match = salaryDesc.match(/(\d+)[-~](\d+)[Kk千]/);
|
||||
if (match) {
|
||||
// 1. 匹配K格式:40-60K, 30-40K·18薪(忽略后面的薪数)
|
||||
const kMatch = salaryDesc.match(/(\d+)[-~](\d+)[Kk千]/);
|
||||
if (kMatch) {
|
||||
return {
|
||||
min: parseInt(match[1]) * 1000,
|
||||
max: parseInt(match[2]) * 1000
|
||||
min: parseInt(kMatch[1]) * 1000,
|
||||
max: parseInt(kMatch[2]) * 1000
|
||||
};
|
||||
}
|
||||
|
||||
// 匹配单个数字 "20K"
|
||||
const singleMatch = salaryDesc.match(/(\d+)[Kk千]/);
|
||||
if (singleMatch) {
|
||||
const value = parseInt(singleMatch[1]) * 1000;
|
||||
// 2. 匹配单个K值:25K
|
||||
const singleKMatch = salaryDesc.match(/(\d+)[Kk千]/);
|
||||
if (singleKMatch) {
|
||||
const value = parseInt(singleKMatch[1]) * 1000;
|
||||
return { min: value, max: value };
|
||||
}
|
||||
|
||||
// 3. 匹配元/月格式:5000-6000元/月
|
||||
const yuanMatch = salaryDesc.match(/(\d+)[-~](\d+)[元万]/);
|
||||
if (yuanMatch) {
|
||||
const min = parseInt(yuanMatch[1]);
|
||||
const max = parseInt(yuanMatch[2]);
|
||||
// 判断单位(万或元)
|
||||
if (salaryDesc.includes('万')) {
|
||||
return {
|
||||
min: min * 10000,
|
||||
max: max * 10000
|
||||
};
|
||||
} else {
|
||||
return { min, max };
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 匹配单个元/月值:5000元/月
|
||||
const singleYuanMatch = salaryDesc.match(/(\d+)[元万]/);
|
||||
if (singleYuanMatch) {
|
||||
const value = parseInt(singleYuanMatch[1]);
|
||||
if (salaryDesc.includes('万')) {
|
||||
return { min: value * 10000, max: value * 10000 };
|
||||
} else {
|
||||
return { min: value, max: value };
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 匹配纯数字格式(如:20000-30000)
|
||||
const numMatch = salaryDesc.match(/(\d+)[-~](\d+)/);
|
||||
if (numMatch) {
|
||||
return {
|
||||
min: parseInt(numMatch[1]),
|
||||
max: parseInt(numMatch[2])
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析期望薪资
|
||||
* @param {string} expectedSalary - 期望薪资描述
|
||||
* @returns {number|null} 期望薪资数值
|
||||
* 解析期望薪资(返回平均值)
|
||||
* @param {string} expectedSalary - 期望薪资描述(如 "20-30K"、"5000-6000元/月")
|
||||
* @returns {number|null} 期望薪资数值(元),如果是范围则返回平均值
|
||||
*/
|
||||
parseExpectedSalary(expectedSalary) {
|
||||
if (!expectedSalary) return null;
|
||||
|
||||
// 匹配数字+K格式
|
||||
const match = expectedSalary.match(/(\d+)[Kk千]/);
|
||||
if (match) {
|
||||
return parseInt(match[1]) * 1000;
|
||||
// 1. 匹配K格式范围:20-30K
|
||||
const kRangeMatch = expectedSalary.match(/(\d+)[-~](\d+)[Kk千]/);
|
||||
if (kRangeMatch) {
|
||||
const min = parseInt(kRangeMatch[1]) * 1000;
|
||||
const max = parseInt(kRangeMatch[2]) * 1000;
|
||||
return (min + max) / 2; // 返回平均值
|
||||
}
|
||||
|
||||
// 匹配纯数字
|
||||
// 2. 匹配单个K值:25K
|
||||
const kMatch = expectedSalary.match(/(\d+)[Kk千]/);
|
||||
if (kMatch) {
|
||||
return parseInt(kMatch[1]) * 1000;
|
||||
}
|
||||
|
||||
// 3. 匹配元/月格式范围:5000-6000元/月
|
||||
const yuanRangeMatch = expectedSalary.match(/(\d+)[-~](\d+)[元万]/);
|
||||
if (yuanRangeMatch) {
|
||||
const min = parseInt(yuanRangeMatch[1]);
|
||||
const max = parseInt(yuanRangeMatch[2]);
|
||||
if (expectedSalary.includes('万')) {
|
||||
return ((min + max) / 2) * 10000;
|
||||
} else {
|
||||
return (min + max) / 2; // 返回平均值
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 匹配单个元/月值:5000元/月
|
||||
const yuanMatch = expectedSalary.match(/(\d+)[元万]/);
|
||||
if (yuanMatch) {
|
||||
const value = parseInt(yuanMatch[1]);
|
||||
if (expectedSalary.includes('万')) {
|
||||
return value * 10000;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 匹配纯数字范围(如:20000-30000)
|
||||
const numRangeMatch = expectedSalary.match(/(\d+)[-~](\d+)/);
|
||||
if (numRangeMatch) {
|
||||
return (parseInt(numRangeMatch[1]) + parseInt(numRangeMatch[2])) / 2; // 返回平均值
|
||||
}
|
||||
|
||||
// 6. 匹配纯数字(如:20000)
|
||||
const numMatch = expectedSalary.match(/(\d+)/);
|
||||
if (numMatch) {
|
||||
return parseInt(numMatch[1]);
|
||||
|
||||
Reference in New Issue
Block a user