251122:1700 Phase 4

This commit is contained in:
admin
2025-11-22 17:21:55 +07:00
parent bf0308e350
commit a3474bff6a
63 changed files with 10062 additions and 109 deletions

View File

@@ -0,0 +1,71 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
ManyToOne,
JoinColumn,
ManyToMany,
JoinTable,
} from 'typeorm';
import { ShopDrawing } from './shop-drawing.entity';
import { ContractDrawing } from './contract-drawing.entity';
import { Attachment } from '../../../common/file-storage/entities/attachment.entity';
@Entity('shop_drawing_revisions')
export class ShopDrawingRevision {
@PrimaryGeneratedColumn()
id!: number; // เติม !
@Column({ name: 'shop_drawing_id' })
shopDrawingId!: number; // เติม !
@Column({ name: 'revision_number' })
revisionNumber!: number; // เติม !
@Column({ name: 'revision_label', length: 10, nullable: true })
revisionLabel?: string; // nullable ใช้ ?
@Column({ name: 'revision_date', type: 'date', nullable: true })
revisionDate?: Date; // nullable ใช้ ?
@Column({ type: 'text', nullable: true })
description?: string; // nullable ใช้ ?
@CreateDateColumn({ name: 'created_at' })
createdAt!: Date; // เติม !
// Relations
@ManyToOne(() => ShopDrawing, (shopDrawing) => shopDrawing.revisions, {
onDelete: 'CASCADE',
})
@JoinColumn({ name: 'shop_drawing_id' })
shopDrawing!: ShopDrawing; // เติม !
// References to Contract Drawings (M:N)
@ManyToMany(() => ContractDrawing)
@JoinTable({
name: 'shop_drawing_revision_contract_refs',
joinColumn: {
name: 'shop_drawing_revision_id',
referencedColumnName: 'id',
},
inverseJoinColumn: {
name: 'contract_drawing_id',
referencedColumnName: 'id',
},
})
contractDrawings!: ContractDrawing[]; // เติม !
// Attachments (M:N)
@ManyToMany(() => Attachment)
@JoinTable({
name: 'shop_drawing_revision_attachments',
joinColumn: {
name: 'shop_drawing_revision_id',
referencedColumnName: 'id',
},
inverseJoinColumn: { name: 'attachment_id', referencedColumnName: 'id' },
})
attachments!: Attachment[]; // เติม ! (ตัวที่ error)
}