-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
user.entity.ts
52 lines (44 loc) · 1.12 KB
/
user.entity.ts
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
import { Column, CreateDateColumn, Entity, Index, OneToMany, UpdateDateColumn, VersionColumn } from 'typeorm';
import { ApiModelProperty } from '@nestjs/swagger';
import { IsAscii, IsEmail, IsNotEmpty, IsString, MaxLength, MinLength } from 'class-validator';
import { Base } from '../core/entities/base.entity';
export enum AccountSourceType {
msId,
hsId,
gitHub,
}
@Entity('user')
export class User extends Base {
@ApiModelProperty({ type: String })
@IsString()
@IsNotEmpty()
@Index()
@Column()
firstName: string;
@ApiModelProperty({ type: String })
@IsString()
@IsNotEmpty()
@Index()
@Column()
lastName: string;
@ApiModelProperty({ type: String, minLength: 10, maxLength: 100 })
@IsEmail()
@IsNotEmpty()
@Index()
@Column()
email: string;
@ApiModelProperty({ type: String, minLength: 8, maxLength: 20 })
@IsAscii()
@IsNotEmpty()
@MinLength(8)
@MaxLength(20)
@Index({ unique: true })
@Column()
userId: string;
@CreateDateColumn({ type: 'timestamptz' })
createdAt?: Date;
@UpdateDateColumn({ type: 'timestamptz' })
updatedAt?: Date;
@VersionColumn()
version?: number;
}