2026-01-28 10:42:06 +08:00
|
|
|
|
import {
|
|
|
|
|
|
Entity,
|
|
|
|
|
|
PrimaryGeneratedColumn,
|
|
|
|
|
|
Column,
|
|
|
|
|
|
CreateDateColumn,
|
|
|
|
|
|
UpdateDateColumn,
|
|
|
|
|
|
ManyToOne,
|
|
|
|
|
|
JoinColumn,
|
|
|
|
|
|
OneToMany,
|
2026-01-28 13:03:28 +08:00
|
|
|
|
} from "typeorm";
|
|
|
|
|
|
import { User } from "./user.entity";
|
|
|
|
|
|
import { GroupMember } from "./group-member.entity";
|
|
|
|
|
|
import { Appointment } from "./appointment.entity";
|
2026-01-28 10:42:06 +08:00
|
|
|
|
|
2026-01-28 13:03:28 +08:00
|
|
|
|
@Entity("groups")
|
2026-01-28 10:42:06 +08:00
|
|
|
|
export class Group {
|
2026-01-28 13:03:28 +08:00
|
|
|
|
@PrimaryGeneratedColumn("uuid")
|
2026-01-28 10:42:06 +08:00
|
|
|
|
id: string;
|
|
|
|
|
|
|
|
|
|
|
|
@Column({ length: 100 })
|
|
|
|
|
|
name: string;
|
|
|
|
|
|
|
2026-01-28 13:03:28 +08:00
|
|
|
|
@Column({ type: "text", nullable: true })
|
2026-01-28 10:42:06 +08:00
|
|
|
|
description: string;
|
|
|
|
|
|
|
2026-01-28 13:03:28 +08:00
|
|
|
|
@Column({ type: "varchar", nullable: true, length: 255 })
|
2026-01-28 10:42:06 +08:00
|
|
|
|
avatar: string;
|
|
|
|
|
|
|
|
|
|
|
|
@Column()
|
|
|
|
|
|
ownerId: string;
|
|
|
|
|
|
|
|
|
|
|
|
@ManyToOne(() => User)
|
2026-01-28 13:03:28 +08:00
|
|
|
|
@JoinColumn({ name: "ownerId" })
|
2026-01-28 10:42:06 +08:00
|
|
|
|
owner: User;
|
|
|
|
|
|
|
2026-01-28 13:03:28 +08:00
|
|
|
|
@Column({ default: "normal", length: 20, comment: "类型: normal/guild" })
|
2026-01-28 10:42:06 +08:00
|
|
|
|
type: string;
|
|
|
|
|
|
|
2026-01-28 13:03:28 +08:00
|
|
|
|
@Column({ nullable: true, comment: "父组ID,用于子组" })
|
2026-01-28 10:42:06 +08:00
|
|
|
|
parentId: string;
|
|
|
|
|
|
|
|
|
|
|
|
@ManyToOne(() => Group, { nullable: true })
|
2026-01-28 13:03:28 +08:00
|
|
|
|
@JoinColumn({ name: "parentId" })
|
2026-01-28 10:42:06 +08:00
|
|
|
|
parent: Group;
|
|
|
|
|
|
|
2026-01-28 13:03:28 +08:00
|
|
|
|
@Column({ type: "text", nullable: true, comment: "公示信息" })
|
2026-01-28 10:42:06 +08:00
|
|
|
|
announcement: string;
|
|
|
|
|
|
|
2026-01-28 13:03:28 +08:00
|
|
|
|
@Column({ default: 50, comment: "最大成员数" })
|
2026-01-28 10:42:06 +08:00
|
|
|
|
maxMembers: number;
|
|
|
|
|
|
|
2026-01-28 13:03:28 +08:00
|
|
|
|
@Column({ default: 1, comment: "当前成员数" })
|
2026-01-28 10:42:06 +08:00
|
|
|
|
currentMembers: number;
|
|
|
|
|
|
|
|
|
|
|
|
@Column({ default: true })
|
|
|
|
|
|
isActive: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
@CreateDateColumn()
|
|
|
|
|
|
createdAt: Date;
|
|
|
|
|
|
|
|
|
|
|
|
@UpdateDateColumn()
|
|
|
|
|
|
updatedAt: Date;
|
|
|
|
|
|
|
|
|
|
|
|
@OneToMany(() => GroupMember, (member) => member.group)
|
|
|
|
|
|
members: GroupMember[];
|
|
|
|
|
|
|
|
|
|
|
|
@OneToMany(() => Appointment, (appointment) => appointment.group)
|
|
|
|
|
|
appointments: Appointment[];
|
|
|
|
|
|
}
|