mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-06 07:57:06 +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:
@@ -296,7 +296,7 @@ export async function mainLoop (hooks) {
|
|||||||
throw new Error('STARTUP_CHAT_ERROR_WITH_UNKNOWN_ERROR')
|
throw new Error('STARTUP_CHAT_ERROR_WITH_UNKNOWN_ERROR')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hooks.newChatStartup?.call(jobData)
|
await hooks.newChatStartup?.promise(jobData)
|
||||||
blockBossNotNewChat.add(jobData.jobInfo.encryptUserId)
|
blockBossNotNewChat.add(jobData.jobInfo.encryptUserId)
|
||||||
|
|
||||||
await storeStorage(page).catch(() => void 0)
|
await storeStorage(page).catch(() => void 0)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ const main = async () => {
|
|||||||
cookieWillSet: new SyncHook(['cookies']),
|
cookieWillSet: new SyncHook(['cookies']),
|
||||||
userInfoResponse: new AsyncSeriesHook(['userInfo']),
|
userInfoResponse: new AsyncSeriesHook(['userInfo']),
|
||||||
newChatWillStartup: new AsyncSeriesHook(['positionInfoDetail']),
|
newChatWillStartup: new AsyncSeriesHook(['positionInfoDetail']),
|
||||||
newChatStartup: new SyncHook(['positionInfoDetail']),
|
newChatStartup: new AsyncSeriesHook(['positionInfoDetail']),
|
||||||
noPositionFoundForCurrentJob: new SyncHook(),
|
noPositionFoundForCurrentJob: new SyncHook(),
|
||||||
noPositionFoundAfterTraverseAllJob: new SyncHook(),
|
noPositionFoundAfterTraverseAllJob: new SyncHook(),
|
||||||
errorEncounter: new SyncHook(['errorInfo'])
|
errorEncounter: new SyncHook(['errorInfo'])
|
||||||
|
|||||||
@@ -15,5 +15,5 @@ export class BossInfo {
|
|||||||
date: Date;
|
date: Date;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
title: Date;
|
title: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export class ChatStartupLog {
|
|||||||
id: number;
|
id: number;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
encryptPositionId: string;
|
encryptJobId: string;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
encryptCurrentUserId: string;
|
encryptCurrentUserId: string;
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ export class CompanyInfo {
|
|||||||
@Column({
|
@Column({
|
||||||
nullable: true
|
nullable: true
|
||||||
})
|
})
|
||||||
scaleLow?: string;
|
scaleLow?: number;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true
|
nullable: true
|
||||||
})
|
})
|
||||||
scaleHeight?: string;
|
scaleHeight?: number;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true
|
nullable: true
|
||||||
|
|||||||
@@ -26,18 +26,13 @@ export class JobInfo {
|
|||||||
})
|
})
|
||||||
salaryMonth?: number;
|
salaryMonth?: number;
|
||||||
|
|
||||||
@Column({
|
|
||||||
nullable: true
|
|
||||||
})
|
|
||||||
experienceYearLow?: number;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
nullable: true
|
|
||||||
})
|
|
||||||
experienceYearHigh?: number;
|
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
publishDate: Date;
|
experienceName: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true
|
||||||
|
})
|
||||||
|
publishDate?: Date;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true
|
nullable: true
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ import { DataSource } from "typeorm";
|
|||||||
|
|
||||||
import { BossInfo } from "./entity/BossInfo";
|
import { BossInfo } from "./entity/BossInfo";
|
||||||
import { BossInfoChangeLog } from "./entity/BossInfoChangeLog";
|
import { BossInfoChangeLog } from "./entity/BossInfoChangeLog";
|
||||||
import { ChatStartupLog } from "./entity/ChatStartupLog";
|
import { ChatStartupLog } from './entity/ChatStartupLog';
|
||||||
import { CompanyInfoChangeLog } from "./entity/CompanyInfoChangeLog";
|
import { CompanyInfoChangeLog } from "./entity/CompanyInfoChangeLog";
|
||||||
import { CompanyInfo } from "./entity/CompanyInfo";
|
import { CompanyInfo } from "./entity/CompanyInfo";
|
||||||
import { JobInfo } from "./entity/JobInfo";
|
import { JobInfo } from "./entity/JobInfo";
|
||||||
import { JobInfoChangeLog } from "./entity/JobInfoChangeLog";
|
import { JobInfoChangeLog } from "./entity/JobInfoChangeLog";
|
||||||
import { BossActiveStatusRecord } from "./entity/BossActiveStatusRecord";
|
import { BossActiveStatusRecord } from "./entity/BossActiveStatusRecord";
|
||||||
import { UserInfo } from "./entity/UserInfo";
|
import { UserInfo } from "./entity/UserInfo";
|
||||||
|
import { parseCompanyScale, parseSalary } from "./utils/parser";
|
||||||
|
|
||||||
async function initDb() {
|
async function initDb() {
|
||||||
const appDataSource = new DataSource({
|
const appDataSource = new DataSource({
|
||||||
@@ -39,21 +40,101 @@ export default class SqlitePlugin {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.initPromise = initDb();
|
this.initPromise = initDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
userInfo = null
|
||||||
|
|
||||||
apply(hooks) {
|
apply(hooks) {
|
||||||
hooks.userInfoResponse.tapPromise("SqlitePlugin", async (userInfoResponse) => {
|
hooks.userInfoResponse.tapPromise(
|
||||||
if (userInfoResponse.code !== 0) {
|
"SqlitePlugin",
|
||||||
return
|
async (userInfoResponse) => {
|
||||||
|
if (userInfoResponse.code !== 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { zpData: userInfo } = userInfoResponse;
|
||||||
|
this.userInfo = userInfo
|
||||||
|
console.log(userInfo);
|
||||||
|
|
||||||
|
const ds = await this.initPromise;
|
||||||
|
const userInfoRepository = ds.getRepository(UserInfo);
|
||||||
|
|
||||||
|
const user = new UserInfo();
|
||||||
|
user.encryptUserId = userInfo.encryptUserId;
|
||||||
|
user.name = userInfo.name;
|
||||||
|
|
||||||
|
return await userInfoRepository.save(user);
|
||||||
}
|
}
|
||||||
const { zpData: userInfo } = userInfoResponse
|
);
|
||||||
console.log(userInfo);
|
|
||||||
|
hooks.newChatStartup.tapPromise("SqlitePlugin", async (_jobInfo) => {
|
||||||
|
console.log(_jobInfo);
|
||||||
|
debugger;
|
||||||
const ds = await this.initPromise;
|
const ds = await this.initPromise;
|
||||||
const userInfoRepository = ds.getRepository(UserInfo);
|
|
||||||
|
|
||||||
const user = new UserInfo();
|
const { bossInfo, brandComInfo, jobInfo } = _jobInfo;
|
||||||
user.encryptUserId = userInfo.encryptUserId
|
|
||||||
user.name = userInfo.name
|
|
||||||
|
|
||||||
return await userInfoRepository.save(user)
|
//#region boss
|
||||||
|
const boss = new BossInfo();
|
||||||
|
boss.encryptBossId = jobInfo.encryptUserId;
|
||||||
|
boss.encryptCompanyId = brandComInfo.encryptBrandId;
|
||||||
|
boss.name = bossInfo.name;
|
||||||
|
boss.title = bossInfo.title;
|
||||||
|
boss.date = new Date();
|
||||||
|
const bossInfoRepository = ds.getRepository(BossInfo);
|
||||||
|
await bossInfoRepository.save(boss);
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region company
|
||||||
|
const company = new CompanyInfo();
|
||||||
|
company.encryptCompanyId = brandComInfo.encryptBrandId;
|
||||||
|
company.brandName = brandComInfo.brandName;
|
||||||
|
company.name = brandComInfo.customerBrandName;
|
||||||
|
company.industryName = brandComInfo.industryName;
|
||||||
|
company.stageName = brandComInfo.stageName;
|
||||||
|
const companyScale = parseCompanyScale(brandComInfo.scaleName)
|
||||||
|
company.scaleLow = companyScale[0]
|
||||||
|
company.scaleHeight = companyScale[1]
|
||||||
|
|
||||||
|
const companyInfoRepository = ds.getRepository(CompanyInfo);
|
||||||
|
await companyInfoRepository.save(company);
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region job
|
||||||
|
const job = new JobInfo();
|
||||||
|
const jobSalary = parseSalary(jobInfo.salaryDesc)
|
||||||
|
const jobUpdatePayload: JobInfo = {
|
||||||
|
address: jobInfo.address,
|
||||||
|
degreeName: jobInfo.degreeName,
|
||||||
|
description: jobInfo.postDescription,
|
||||||
|
encryptBossId: jobInfo.encryptUserId,
|
||||||
|
encryptCompanyId: brandComInfo.encryptBrandId,
|
||||||
|
encryptJobId: jobInfo.encryptId,
|
||||||
|
jobName: jobInfo.jobName,
|
||||||
|
positionName: jobInfo.positionName,
|
||||||
|
experienceName: jobInfo.experienceName,
|
||||||
|
salaryHeight: jobSalary.heigh,
|
||||||
|
salaryLow: jobSalary.low,
|
||||||
|
salaryMonth: jobSalary.month,
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.assign(job, jobUpdatePayload);
|
||||||
|
|
||||||
|
const jobInfoRepository = ds.getRepository(JobInfo);
|
||||||
|
await jobInfoRepository.save(job);
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region chat-startup-log
|
||||||
|
const chatStartupLog = new ChatStartupLog()
|
||||||
|
const chatStartupLogPayload: Partial<ChatStartupLog> = {
|
||||||
|
date: new Date(),
|
||||||
|
encryptCurrentUserId: this.userInfo.encryptUserId,
|
||||||
|
encryptJobId: jobInfo.encryptId,
|
||||||
|
}
|
||||||
|
Object.assign(chatStartupLog, chatStartupLogPayload)
|
||||||
|
|
||||||
|
const chatStartupLogRepository = ds.getRepository(ChatStartupLog);
|
||||||
|
await chatStartupLogRepository.save(chatStartupLog);
|
||||||
|
//#endregion
|
||||||
|
return
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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