From bb11ca1880886167f1cbfc22ecf8fc8aad3ad28a Mon Sep 17 00:00:00 2001 From: wangziqi Date: Sun, 5 Jul 2026 22:56:54 +0800 Subject: [PATCH] feat: add Notification entity --- apps/server/src/entities/index.ts | 2 + .../src/entities/notification.entity.ts | 55 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 apps/server/src/entities/notification.entity.ts diff --git a/apps/server/src/entities/index.ts b/apps/server/src/entities/index.ts index 2287f63..f8aecea 100644 --- a/apps/server/src/entities/index.ts +++ b/apps/server/src/entities/index.ts @@ -22,3 +22,5 @@ export { AttendanceRecord } from './attendance-record.entity'; export { DingAttendanceRaw } from './ding-attendance-raw.entity'; export { SyncLog } from './sync-log.entity'; export { SyncState } from './sync-state.entity'; +export { ExpenseType } from './expense-type.entity'; +export { Notification, NotificationType } from './notification.entity'; diff --git a/apps/server/src/entities/notification.entity.ts b/apps/server/src/entities/notification.entity.ts new file mode 100644 index 0000000..a3ebdf4 --- /dev/null +++ b/apps/server/src/entities/notification.entity.ts @@ -0,0 +1,55 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + ManyToOne, + JoinColumn, +} from 'typeorm'; +import { User } from './user.entity'; + +export enum NotificationType { + BILL_GENERATED = 'bill_generated', + BILL_PAID = 'bill_paid', + CHECK_IN = 'check_in', + CHECK_OUT = 'check_out', + DEPOSIT_DUE = 'deposit_due', + DEPOSIT_REFUNDED = 'deposit_refunded', + CLASS_CHANGE = 'class_change', + SCHEDULE_CONFLICT = 'schedule_conflict', + ANNOUNCEMENT = 'announcement', +} + +@Entity('notifications') +export class Notification { + @PrimaryGeneratedColumn() + id: number; + + @Column({ name: 'recipient_id', type: 'integer' }) + recipientId: number; + + @ManyToOne(() => User, { onDelete: 'CASCADE' }) + @JoinColumn({ name: 'recipient_id' }) + recipient: User; + + @Column({ name: 'type', length: 30 }) + type: string; + + @Column({ name: 'title', length: 200 }) + title: string; + + @Column({ name: 'content', type: 'text', nullable: true }) + content: string; + + @Column({ name: 'link', length: 500, nullable: true }) + link: string; + + @Column({ name: 'is_read', type: 'boolean', default: false }) + isRead: boolean; + + @Column({ name: 'read_at', type: 'datetime', nullable: true }) + readAt: Date; + + @CreateDateColumn({ name: 'created_at' }) + createdAt: Date; +}