add the logic to save chat record when open boss manually

This commit is contained in:
geekgeekrun
2024-11-03 23:12:58 +08:00
parent 2aa8bb05bb
commit d531c07e8b
4 changed files with 114 additions and 1 deletions

View File

@@ -0,0 +1,49 @@
import { requireTypeorm } from "../utils/module-loader";
const { Entity, Column, PrimaryGeneratedColumn } = requireTypeorm()
@Entity()
export class ChatMessageRecord {
@PrimaryGeneratedColumn()
mid: number;
@Column()
encryptFromUserId: string;
@Column()
encryptToUserId: string;
@Column({
nullable: true
})
time: Date | null;
@Column({
nullable: true
})
type?: 'text' | 'image' | 'resume';
@Column({
nullable: true
})
style?: 'sent' | 'receive';
@Column({
nullable: true
})
text: string;
@Column({
nullable: true
})
imageUrl?: string;
@Column({
nullable: true
})
imageWidth?: number;
@Column({
nullable: true
})
imageHeight?: number;
}

View File

@@ -9,6 +9,7 @@ import { BossInfoChangeLog } from "./entity/BossInfoChangeLog";
import { CompanyInfoChangeLog } from "./entity/CompanyInfoChangeLog";
import { JobInfoChangeLog } from "./entity/JobInfoChangeLog";
import { MarkAsNotSuitLog } from "./entity/MarkAsNotSuitLog";
import { ChatMessageRecord } from "./entity/ChatMessageRecord";
function getBossInfoIfIsEqual (savedOne, currentOne) {
if (savedOne === currentOne) {
@@ -290,3 +291,19 @@ export async function saveMarkAsNotSuitRecord(
//#endregion
return
}
export async function saveChatMessageRecord(
ds: DataSource,
records: ChatMessageRecord[]
) {
//#region mark-as-not-suit-log
const chatMessageRecordList = records.map(it => {
const o = new ChatMessageRecord()
Object.assign(o, it)
return o
})
const chatMessageRecordRepository = ds.getRepository(ChatMessageRecord);
await chatMessageRecordRepository.save(chatMessageRecordList);
//#endregion
return
}

View File

@@ -18,6 +18,7 @@ import { VBossLibrary } from "./entity/VBossLibrary";
import { VJobLibrary } from "./entity/VJobLibrary";
import { VCompanyLibrary } from "./entity/VCompanyLibrary"
import { VMarkAsNotSuitLog } from "./entity/VMarkAsNotSuitLog"
import { ChatMessageRecord } from './entity/ChatMessageRecord'
import sqlite3 from 'sqlite3';
import * as cliHighlight from 'cli-highlight';
@@ -53,6 +54,7 @@ export function initDb(dbFilePath) {
VCompanyLibrary,
MarkAsNotSuitLog,
VMarkAsNotSuitLog,
ChatMessageRecord,
],
migrations: [
UpdateChatStartupLogTable1729182577167