mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-05-21 00:00:37 +08:00
add the logic to save chat record when open boss manually
This commit is contained in:
49
packages/sqlite-plugin/src/entity/ChatMessageRecord.ts
Normal file
49
packages/sqlite-plugin/src/entity/ChatMessageRecord.ts
Normal 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;
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user