forked from hangshuo652/aurak
80 lines
1.9 KiB
TypeScript
80 lines
1.9 KiB
TypeScript
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
ManyToOne,
|
|
OneToOne,
|
|
JoinColumn,
|
|
OneToMany,
|
|
Unique,
|
|
} from 'typeorm';
|
|
import { Tenant } from '../../tenant/tenant.entity';
|
|
import { AssessmentTemplate } from './assessment-template.entity';
|
|
import type { QuestionBankItem } from './question-bank-item.entity';
|
|
|
|
export enum QuestionBankStatus {
|
|
DRAFT = 'DRAFT',
|
|
PENDING_REVIEW = 'PENDING_REVIEW',
|
|
PUBLISHED = 'PUBLISHED',
|
|
REJECTED = 'REJECTED',
|
|
}
|
|
|
|
@Entity('question_banks')
|
|
@Unique(['templateId'])
|
|
export class QuestionBank {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ name: 'tenant_id', nullable: true })
|
|
tenantId: string | null;
|
|
|
|
@ManyToOne(() => Tenant, { nullable: true, onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'tenant_id' })
|
|
tenant: Tenant;
|
|
|
|
@Column({ name: 'template_id', nullable: true })
|
|
templateId: string | null;
|
|
|
|
@OneToOne(() => AssessmentTemplate, { nullable: true })
|
|
@JoinColumn({ name: 'template_id' })
|
|
template: AssessmentTemplate;
|
|
|
|
@Column()
|
|
name: string;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
description: string | null;
|
|
|
|
@Column({
|
|
type: 'simple-enum',
|
|
enum: QuestionBankStatus,
|
|
default: QuestionBankStatus.DRAFT,
|
|
})
|
|
status: QuestionBankStatus;
|
|
|
|
@Column({ name: 'created_by', nullable: true, type: 'text' })
|
|
createdBy: string | null;
|
|
|
|
@Column({ name: 'reviewed_by', nullable: true, type: 'text' })
|
|
reviewedBy: string | null;
|
|
|
|
@Column({ name: 'reviewed_at', nullable: true, type: 'datetime' })
|
|
reviewedAt: Date | null;
|
|
|
|
@Column({ name: 'review_comment', nullable: true, type: 'text' })
|
|
reviewComment: string | null;
|
|
|
|
@OneToMany(
|
|
'QuestionBankItem',
|
|
(item: QuestionBankItem) => item.bank,
|
|
)
|
|
items: QuestionBankItem[];
|
|
|
|
@CreateDateColumn({ name: 'created_at' })
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at' })
|
|
updatedAt: Date;
|
|
} |