70 lines
1.6 KiB
TypeScript
70 lines
1.6 KiB
TypeScript
|
|
import {
|
|||
|
|
Entity,
|
|||
|
|
PrimaryGeneratedColumn,
|
|||
|
|
Column,
|
|||
|
|
CreateDateColumn,
|
|||
|
|
UpdateDateColumn,
|
|||
|
|
ManyToOne,
|
|||
|
|
JoinColumn,
|
|||
|
|
OneToMany,
|
|||
|
|
} from 'typeorm';
|
|||
|
|
import { User } from './user.entity';
|
|||
|
|
import { GroupMember } from './group-member.entity';
|
|||
|
|
import { Appointment } from './appointment.entity';
|
|||
|
|
|
|||
|
|
@Entity('groups')
|
|||
|
|
export class Group {
|
|||
|
|
@PrimaryGeneratedColumn('uuid')
|
|||
|
|
id: string;
|
|||
|
|
|
|||
|
|
@Column({ length: 100 })
|
|||
|
|
name: string;
|
|||
|
|
|
|||
|
|
@Column({ type: 'text', nullable: true })
|
|||
|
|
description: string;
|
|||
|
|
|
|||
|
|
@Column({ type: 'varchar', nullable: true, length: 255 })
|
|||
|
|
avatar: string;
|
|||
|
|
|
|||
|
|
@Column()
|
|||
|
|
ownerId: string;
|
|||
|
|
|
|||
|
|
@ManyToOne(() => User)
|
|||
|
|
@JoinColumn({ name: 'ownerId' })
|
|||
|
|
owner: User;
|
|||
|
|
|
|||
|
|
@Column({ default: 'normal', length: 20, comment: '类型: normal/guild' })
|
|||
|
|
type: string;
|
|||
|
|
|
|||
|
|
@Column({ nullable: true, comment: '父组ID,用于子组' })
|
|||
|
|
parentId: string;
|
|||
|
|
|
|||
|
|
@ManyToOne(() => Group, { nullable: true })
|
|||
|
|
@JoinColumn({ name: 'parentId' })
|
|||
|
|
parent: Group;
|
|||
|
|
|
|||
|
|
@Column({ type: 'text', nullable: true, comment: '公示信息' })
|
|||
|
|
announcement: string;
|
|||
|
|
|
|||
|
|
@Column({ default: 50, comment: '最大成员数' })
|
|||
|
|
maxMembers: number;
|
|||
|
|
|
|||
|
|
@Column({ default: 1, comment: '当前成员数' })
|
|||
|
|
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[];
|
|||
|
|
}
|