1
|
|
|
import {Entity, Column, PrimaryGeneratedColumn, ManyToOne} from 'typeorm'; |
2
|
|
|
import {User} from '../User/User.entity'; |
3
|
|
|
|
4
|
|
|
export enum HolidayStatus { |
5
|
|
|
WAITING = 'waiting', |
6
|
|
|
ACCEPTED = 'accepted', |
7
|
|
|
REFUSED = 'refused' |
8
|
|
|
} |
9
|
|
|
|
10
|
|
|
export enum HolidayLeaveType { |
11
|
|
|
PAID = 'paid', |
12
|
|
|
UNPAID = 'unpaid', |
13
|
|
|
SPECIAL = 'special', |
14
|
|
|
MEDICAL = 'medical' |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
@Entity() |
18
|
|
|
export class Holiday { |
19
|
|
|
@PrimaryGeneratedColumn('uuid') |
20
|
|
|
private id: string; |
21
|
|
|
|
22
|
|
|
@Column('enum', {enum: HolidayStatus, nullable: false}) |
23
|
|
|
private status: HolidayStatus; |
24
|
|
|
|
25
|
|
|
@Column('enum', {enum: HolidayLeaveType, nullable: false}) |
26
|
|
|
private leaveType: HolidayLeaveType; |
27
|
|
|
|
28
|
|
|
@Column({type: 'timestamp', nullable: false}) |
29
|
|
|
private startDate: string; |
30
|
|
|
|
31
|
|
|
@Column({type: 'boolean', nullable: false, default: true}) |
32
|
|
|
private startsAllDay: boolean; |
33
|
|
|
|
34
|
|
|
@Column({type: 'timestamp', nullable: false}) |
35
|
|
|
private endDate: string; |
36
|
|
|
|
37
|
|
|
@Column({type: 'boolean', nullable: false, default: true}) |
38
|
|
|
private endsAllDay: boolean; |
39
|
|
|
|
40
|
|
|
@Column({type: 'varchar', nullable: true}) |
41
|
|
|
private comment: string; |
42
|
|
|
|
43
|
|
|
@Column({type: 'timestamp', nullable: true}) |
44
|
|
|
private moderateAt: string; |
45
|
|
|
|
46
|
|
|
@ManyToOne(type => User, {nullable: true}) |
47
|
|
|
private moderator: User; |
48
|
|
|
|
49
|
|
|
@ManyToOne(type => User, {nullable: false}) |
50
|
|
|
private user: User; |
51
|
|
|
|
52
|
|
|
constructor( |
53
|
|
|
user: User, |
54
|
|
|
|
55
|
|
|
leaveType: HolidayLeaveType, |
56
|
|
|
startDate: string, |
57
|
|
|
startsAllDay: boolean, |
58
|
|
|
endDate: string, |
59
|
|
|
endsAllDay: boolean, |
60
|
|
|
comment?: string |
61
|
|
|
) { |
62
|
|
|
this.status = HolidayStatus.WAITING; |
63
|
|
|
this.user = user; |
64
|
|
|
this.leaveType = leaveType; |
65
|
|
|
this.startDate = startDate; |
66
|
|
|
this.startsAllDay = startsAllDay; |
67
|
|
|
this.endDate = endDate; |
68
|
|
|
this.endsAllDay = endsAllDay; |
69
|
|
|
this.comment = comment; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public getId(): string { |
73
|
|
|
return this.id; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public getUser(): User { |
77
|
|
|
return this.user; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public getStatus(): HolidayStatus { |
81
|
|
|
return this.status; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public getLeaveType(): HolidayLeaveType { |
85
|
|
|
return this.leaveType; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public getStartDate(): string { |
89
|
|
|
return this.startDate; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public isStartsAllDay(): boolean { |
93
|
|
|
return this.startsAllDay; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public getEndDate(): string { |
97
|
|
|
return this.endDate; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public isEndsAllDay(): boolean { |
101
|
|
|
return this.endsAllDay; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public getComment(): string { |
105
|
|
|
return this.comment; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|