mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-05-25 18:20:14 +08:00
enhance run core - add the logic to save the start chat logic to db; modify some entity with wrong type.
This commit is contained in:
67
packages/sqlite-plugin/src/utils/parser.ts
Normal file
67
packages/sqlite-plugin/src/utils/parser.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
export const parseCompanyScale = (str: string): [number| null, number | null] => {
|
||||
if (!str) {
|
||||
return [null, null]
|
||||
}
|
||||
|
||||
const betweenRangeMatchResult = str.match(
|
||||
/(\d+)-(\d+)人/
|
||||
);
|
||||
if (betweenRangeMatchResult) {
|
||||
const arr = [...betweenRangeMatchResult];
|
||||
arr.shift();
|
||||
return arr.map(Number) as [number, number]
|
||||
}
|
||||
|
||||
const gtRangeMatchResult = str.match(
|
||||
/(\d+)人以上/
|
||||
);
|
||||
if (gtRangeMatchResult) {
|
||||
const arr = [...gtRangeMatchResult];
|
||||
arr.shift();
|
||||
return [Number(arr[0]), null]
|
||||
}
|
||||
|
||||
return [null, null]
|
||||
}
|
||||
|
||||
export const parseSalary = (str: string): { low: null | number, heigh: null | number, month: null | number } => {
|
||||
const result = {
|
||||
heigh: null,
|
||||
low: null,
|
||||
month: null
|
||||
}
|
||||
if (!str) {
|
||||
return result
|
||||
}
|
||||
|
||||
const baseMatchResult = str.match(
|
||||
/([\.\d]+)-([\.\d]+)k/i
|
||||
);
|
||||
if (baseMatchResult) {
|
||||
const arr = [...baseMatchResult];
|
||||
arr.shift();
|
||||
Object.assign(
|
||||
result,
|
||||
{
|
||||
low: Number(arr[0]),
|
||||
heigh: Number(arr[1]),
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const month = str.match(
|
||||
/([\.\d]+)薪/
|
||||
)
|
||||
if (month) {
|
||||
const arr = [...month];
|
||||
arr.shift();
|
||||
Object.assign(
|
||||
result,
|
||||
{
|
||||
month: Number(arr[0])
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user