1
|
|
|
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm'; |
2
|
|
|
import { User } from '../HumanResource/User/User.entity'; |
3
|
|
|
|
4
|
|
|
@Entity() |
5
|
|
|
export class Contact { |
6
|
|
|
@PrimaryGeneratedColumn('uuid') |
7
|
|
|
private id: string; |
8
|
|
|
|
9
|
|
|
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }) |
10
|
|
|
private createdAt: Date; |
11
|
|
|
|
12
|
|
|
@Column({ type: 'varchar', nullable: true }) |
13
|
|
|
private firstName: string; |
14
|
|
|
|
15
|
|
|
@Column({ type: 'varchar', nullable: true }) |
16
|
|
|
private lastName: string; |
17
|
|
|
|
18
|
|
|
@Column({ type: 'varchar', nullable: true }) |
19
|
|
|
private company: string; |
20
|
|
|
|
21
|
|
|
@Column({ type: 'varchar', nullable: true }) |
22
|
|
|
private email: string; |
23
|
|
|
|
24
|
|
|
@Column({ type: 'varchar', nullable: true }) |
25
|
|
|
private phoneNumber: string; |
26
|
|
|
|
27
|
|
|
@Column({ type: 'varchar', nullable: true }) |
28
|
|
|
private notes: string; |
29
|
|
|
|
30
|
|
|
@ManyToOne(type => User, { nullable: true, onDelete: 'SET NULL' }) |
31
|
|
|
private contactedBy?: User; |
32
|
|
|
|
33
|
|
|
constructor( |
34
|
|
|
firstName: string, |
35
|
|
|
lastName: string, |
36
|
|
|
company: string, |
37
|
|
|
email: string, |
38
|
|
|
phoneNumber: string, |
39
|
|
|
notes: string, |
40
|
|
|
contactedBy?: User |
41
|
|
|
) { |
42
|
|
|
this.firstName = firstName; |
43
|
|
|
this.lastName = lastName; |
44
|
|
|
this.company = company; |
45
|
|
|
this.email = email; |
46
|
|
|
this.phoneNumber = phoneNumber; |
47
|
|
|
this.notes = notes; |
48
|
|
|
this.contactedBy = contactedBy; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public getId(): string | null { |
52
|
|
|
return this.id; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public getCreatedAt(): Date { |
56
|
|
|
return this.createdAt; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public getFirstName(): string | null { |
60
|
|
|
return this.firstName; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public getLastName(): string | null { |
64
|
|
|
return this.lastName; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public getCompany(): string | null { |
68
|
|
|
return this.company; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public getEmail(): string | null { |
72
|
|
|
return this.email; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public getPhoneNumber(): string { |
76
|
|
|
return this.phoneNumber; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public getNotes(): string { |
80
|
|
|
return this.notes; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public getContactedBy(): User | null { |
84
|
|
|
return this.contactedBy; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public update( |
88
|
|
|
firstName: string, |
89
|
|
|
lastName: string, |
90
|
|
|
company: string, |
91
|
|
|
email: string, |
92
|
|
|
phoneNumber: string, |
93
|
|
|
notes: string, |
94
|
|
|
contactedBy?: User |
95
|
|
|
): void { |
96
|
|
|
this.firstName = firstName; |
97
|
|
|
this.lastName = lastName; |
98
|
|
|
this.company = company; |
99
|
|
|
this.email = email; |
100
|
|
|
this.phoneNumber = phoneNumber; |
101
|
|
|
this.notes = notes; |
102
|
|
|
this.contactedBy = contactedBy; |
103
|
|
|
} |
104
|
|
|
} |