feat: add validation for documents

This commit is contained in:
Abdalhamid Alhamad
2025-01-13 11:43:28 +03:00
parent 756e947c8a
commit 62621c1a15
12 changed files with 195 additions and 13 deletions
+17 -1
View File
@@ -1,4 +1,13 @@
import { Column, Entity, OneToMany, OneToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
import {
Column,
Entity,
JoinColumn,
ManyToOne,
OneToMany,
OneToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { Customer } from '~/customer/entities';
import { Gift } from '~/gift/entities';
import { Junior, Theme } from '~/junior/entities';
@@ -22,6 +31,9 @@ export class Document {
@Column({ type: 'varchar', length: 255, name: 'document_type' })
documentType!: DocumentType;
@Column({ type: 'uuid', nullable: true, name: 'created_by_id' })
createdById!: string;
@OneToOne(() => Customer, (customer) => customer.profilePicture, { onDelete: 'SET NULL' })
customerPicture?: Customer;
@@ -46,6 +58,10 @@ export class Document {
@OneToMany(() => Gift, (gift) => gift.image)
gifts?: Gift[];
@ManyToOne(() => User, (user) => user.createdDocuments, { nullable: true, onDelete: 'SET NULL' })
@JoinColumn({ name: 'created_by_id' })
createdBy?: User;
@UpdateDateColumn({ name: 'updated_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
updatedAt!: Date;