import { Entity, Column, BaseEntity, PrimaryGeneratedColumn, OneToMany, ManyToOne, Relation, JoinColumn, } from 'typeorm'; import { BranchEntity } from './branch.entity.js'; import { RoleEntity } from './role.entity.js'; import { IsOptional } from 'class-validator'; @Entity('users') export class UserEntity extends BaseEntity { @PrimaryGeneratedColumn('uuid') id: string; @IsOptional() @Column({ nullable: true }) avatar: string; @Column({ nullable: true }) full_name: string; @Column({ nullable: true }) phone_number: string; @Column({ nullable: true }) address: string; @Column({ nullable: true }) email: string; @IsOptional() @Column({ nullable: true }) role_id: number; @Column({ nullable: true }) hash_password: string; @IsOptional() @Column({ default: true }) is_valid: boolean; @IsOptional() @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }) create_at: Date; @IsOptional() @OneToMany(() => BranchEntity, (branch) => branch.owner) branches: Relation[]; @IsOptional() @ManyToOne(() => RoleEntity) @JoinColumn({ name: 'role_id'}) role: RoleEntity; }