File size: 1,034 Bytes
c114c72
 
 
 
 
 
9ec4f32
c114c72
9ec4f32
c114c72
 
9ec4f32
3cdf53d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c114c72
3cdf53d
 
 
 
 
c114c72
 
 
 
9ec4f32
 
 
 
3cdf53d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {
  Entity,
  Column,
  BaseEntity,
  PrimaryGeneratedColumn,
  OneToMany,
  ManyToOne,
  Relation,
  JoinColumn,
} from 'typeorm';
import { BranchEntity } from './branch.entity.js';
import { RoleEntity } from './role.entity.js';

@Entity('users')
export class UserEntity extends BaseEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @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;

  @Column({ nullable: true })
  role_id: number;

  @Column({ nullable: true })
  hash_password: string;

  @Column({ default: true })
  is_valid: boolean;

  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
  create_at: Date;

  @OneToMany(() => BranchEntity, (branch) => branch.owner)
  branches: Relation<BranchEntity>[];

  @ManyToOne(() => RoleEntity)
  @JoinColumn({ name: 'role_id'})
  role: RoleEntity;
}