mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-25 21:59:40 +00:00
79 lines
2.3 KiB
TypeScript
79 lines
2.3 KiB
TypeScript
import {
|
|
BaseEntity,
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
OneToMany,
|
|
OneToOne,
|
|
PrimaryColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { Customer } from '~/customer/entities';
|
|
import { Document } from '~/document/entities';
|
|
import { Guardian } from '~/guardian/entities/guradian.entity';
|
|
import { Category, SavingGoal } from '~/saving-goals/entities';
|
|
import { Task } from '~/task/entities';
|
|
import { Relationship } from '../enums';
|
|
import { JuniorRegistrationToken } from './junior-registration-token.entity';
|
|
import { Theme } from './theme.entity';
|
|
|
|
@Entity('juniors')
|
|
export class Junior extends BaseEntity {
|
|
@PrimaryColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column('varchar', { length: 255 })
|
|
relationship!: Relationship;
|
|
|
|
@Column('uuid', { name: 'civil_id_front_id' })
|
|
civilIdFrontId!: string;
|
|
|
|
@Column('uuid', { name: 'civil_id_back_id' })
|
|
civilIdBackId!: string;
|
|
|
|
@Column('uuid', { name: 'customer_id' })
|
|
customerId!: string;
|
|
|
|
@Column('uuid', { name: 'guardian_id' })
|
|
guardianId!: string;
|
|
|
|
@OneToOne(() => Document, (document) => document.juniorCivilIdFront)
|
|
@JoinColumn({ name: 'civil_id_front_id' })
|
|
civilIdFront!: Document;
|
|
|
|
@OneToOne(() => Document, (document) => document.juniorCivilIdBack)
|
|
@JoinColumn({ name: 'civil_id_back_id' })
|
|
civilIdBack!: Document;
|
|
|
|
@OneToOne(() => Customer, (customer) => customer.junior, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'customer_id' })
|
|
customer!: Customer;
|
|
|
|
@OneToOne(() => Theme, (theme) => theme.junior, { cascade: true, nullable: true })
|
|
theme!: Theme;
|
|
|
|
@ManyToOne(() => Guardian, (guardian) => guardian.juniors)
|
|
@JoinColumn({ name: 'guardian_id' })
|
|
guardian!: Guardian;
|
|
|
|
@OneToMany(() => Task, (task) => task.assignedTo)
|
|
tasks!: Task[];
|
|
|
|
@OneToMany(() => SavingGoal, (savingGoal) => savingGoal.junior)
|
|
goals!: SavingGoal[];
|
|
|
|
@OneToMany(() => Category, (category) => category.junior)
|
|
categories!: Category[];
|
|
|
|
@OneToMany(() => JuniorRegistrationToken, (token) => token.junior)
|
|
registrationTokens!: JuniorRegistrationToken[];
|
|
|
|
@CreateDateColumn({ name: 'created_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
createdAt!: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
updatedAt!: Date;
|
|
}
|