mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-07-08 22:02:55 +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:
@@ -3,13 +3,14 @@ import { DataSource } from "typeorm";
|
||||
|
||||
import { BossInfo } from "./entity/BossInfo";
|
||||
import { BossInfoChangeLog } from "./entity/BossInfoChangeLog";
|
||||
import { ChatStartupLog } from "./entity/ChatStartupLog";
|
||||
import { ChatStartupLog } from './entity/ChatStartupLog';
|
||||
import { CompanyInfoChangeLog } from "./entity/CompanyInfoChangeLog";
|
||||
import { CompanyInfo } from "./entity/CompanyInfo";
|
||||
import { JobInfo } from "./entity/JobInfo";
|
||||
import { JobInfoChangeLog } from "./entity/JobInfoChangeLog";
|
||||
import { BossActiveStatusRecord } from "./entity/BossActiveStatusRecord";
|
||||
import { UserInfo } from "./entity/UserInfo";
|
||||
import { parseCompanyScale, parseSalary } from "./utils/parser";
|
||||
|
||||
async function initDb() {
|
||||
const appDataSource = new DataSource({
|
||||
@@ -39,21 +40,101 @@ export default class SqlitePlugin {
|
||||
constructor() {
|
||||
this.initPromise = initDb();
|
||||
}
|
||||
|
||||
userInfo = null
|
||||
|
||||
apply(hooks) {
|
||||
hooks.userInfoResponse.tapPromise("SqlitePlugin", async (userInfoResponse) => {
|
||||
if (userInfoResponse.code !== 0) {
|
||||
return
|
||||
hooks.userInfoResponse.tapPromise(
|
||||
"SqlitePlugin",
|
||||
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 userInfoRepository = ds.getRepository(UserInfo);
|
||||
|
||||
const user = new UserInfo();
|
||||
user.encryptUserId = userInfo.encryptUserId
|
||||
user.name = userInfo.name
|
||||
const { bossInfo, brandComInfo, jobInfo } = _jobInfo;
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user