This commit is contained in:
@@ -1,39 +1,27 @@
|
||||
// File: src/modules/rfa/entities/rfa-revision.entity.ts
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
Unique,
|
||||
PrimaryColumn,
|
||||
OneToOne,
|
||||
} from 'typeorm';
|
||||
import { User } from '../../user/entities/user.entity';
|
||||
import { CorrespondenceRevision } from '../../correspondence/entities/correspondence-revision.entity';
|
||||
import { RfaApproveCode } from './rfa-approve-code.entity';
|
||||
import { RfaItem } from './rfa-item.entity';
|
||||
import { RfaStatusCode } from './rfa-status-code.entity';
|
||||
import { RfaWorkflow } from './rfa-workflow.entity';
|
||||
import { Rfa } from './rfa.entity';
|
||||
|
||||
@Entity('rfa_revisions')
|
||||
@Unique(['rfaId', 'revisionNumber'])
|
||||
@Unique(['rfaId', 'isCurrent'])
|
||||
export class RfaRevision {
|
||||
@PrimaryGeneratedColumn()
|
||||
@PrimaryColumn()
|
||||
id!: number;
|
||||
|
||||
@Column({ name: 'rfa_id' })
|
||||
rfaId!: number;
|
||||
|
||||
@Column({ name: 'revision_number' })
|
||||
revisionNumber!: number;
|
||||
|
||||
@Column({ name: 'revision_label', length: 10, nullable: true })
|
||||
revisionLabel?: string;
|
||||
|
||||
@Column({ name: 'is_current', default: false })
|
||||
isCurrent!: boolean;
|
||||
@OneToOne(() => CorrespondenceRevision, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'id' })
|
||||
correspondenceRevision!: CorrespondenceRevision;
|
||||
|
||||
@Column({ name: 'rfa_status_code_id' })
|
||||
rfaStatusCodeId!: number;
|
||||
@@ -41,33 +29,9 @@ export class RfaRevision {
|
||||
@Column({ name: 'rfa_approve_code_id', nullable: true })
|
||||
rfaApproveCodeId?: number;
|
||||
|
||||
@Column({ length: 500 })
|
||||
subject!: string;
|
||||
|
||||
@Column({ name: 'document_date', type: 'date', nullable: true })
|
||||
documentDate?: Date;
|
||||
|
||||
@Column({ name: 'issued_date', type: 'date', nullable: true })
|
||||
issuedDate?: Date;
|
||||
|
||||
@Column({ name: 'received_date', type: 'datetime', nullable: true })
|
||||
receivedDate?: Date;
|
||||
|
||||
@Column({ name: 'due_date', type: 'datetime', nullable: true })
|
||||
dueDate?: Date;
|
||||
|
||||
@Column({ name: 'approved_date', type: 'date', nullable: true })
|
||||
approvedDate?: Date;
|
||||
|
||||
@Column({ type: 'text', nullable: true })
|
||||
description?: string;
|
||||
|
||||
@Column({ type: 'text', nullable: true })
|
||||
body?: string;
|
||||
|
||||
@Column({ type: 'text', nullable: true })
|
||||
remarks?: string;
|
||||
|
||||
// --- JSON & Schema Section ---
|
||||
|
||||
@Column({ type: 'json', nullable: true })
|
||||
@@ -87,23 +51,8 @@ export class RfaRevision {
|
||||
})
|
||||
vRefDrawingCount?: number;
|
||||
|
||||
// --- Timestamp ---
|
||||
|
||||
@CreateDateColumn({ name: 'created_at' })
|
||||
createdAt!: Date;
|
||||
|
||||
@Column({ name: 'created_by', nullable: true })
|
||||
createdBy?: number;
|
||||
|
||||
@Column({ name: 'updated_by', nullable: true })
|
||||
updatedBy?: number;
|
||||
|
||||
// --- Relations ---
|
||||
|
||||
@ManyToOne(() => Rfa)
|
||||
@JoinColumn({ name: 'rfa_id' })
|
||||
rfa!: Rfa;
|
||||
|
||||
@ManyToOne(() => RfaStatusCode)
|
||||
@JoinColumn({ name: 'rfa_status_code_id' })
|
||||
statusCode!: RfaStatusCode;
|
||||
@@ -112,10 +61,6 @@ export class RfaRevision {
|
||||
@JoinColumn({ name: 'rfa_approve_code_id' })
|
||||
approveCode?: RfaApproveCode;
|
||||
|
||||
@ManyToOne(() => User)
|
||||
@JoinColumn({ name: 'created_by' })
|
||||
creator?: User;
|
||||
|
||||
@OneToMany(() => RfaItem, (item) => item.rfaRevision, { cascade: true })
|
||||
items!: RfaItem[];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user