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