feat: add Notification entity

This commit is contained in:
2026-07-05 22:56:54 +08:00
parent 1cb2137f61
commit bb11ca1880
2 changed files with 57 additions and 0 deletions

View File

@@ -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';

View File

@@ -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;
}