@hed-hog/contact 0.0.266 → 0.0.270

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/address-type.enum.d.ts +10 -0
  2. package/dist/address-type.enum.d.ts.map +1 -0
  3. package/dist/address-type.enum.js +14 -0
  4. package/dist/address-type.enum.js.map +1 -0
  5. package/dist/contact.module.d.ts.map +1 -1
  6. package/dist/contact.module.js +0 -2
  7. package/dist/contact.module.js.map +1 -1
  8. package/dist/contact.service.d.ts +19 -22
  9. package/dist/contact.service.d.ts.map +1 -1
  10. package/dist/contact.service.js +22 -2
  11. package/dist/contact.service.js.map +1 -1
  12. package/dist/index.d.ts +5 -8
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +1 -4
  15. package/dist/index.js.map +1 -1
  16. package/dist/person/dto/create.dto.d.ts +14 -0
  17. package/dist/person/dto/create.dto.d.ts.map +1 -1
  18. package/dist/person/dto/create.dto.js +52 -1
  19. package/dist/person/dto/create.dto.js.map +1 -1
  20. package/dist/person/dto/update.dto.d.ts +17 -1
  21. package/dist/person/dto/update.dto.d.ts.map +1 -1
  22. package/dist/person/dto/update.dto.js +79 -3
  23. package/dist/person/dto/update.dto.js.map +1 -1
  24. package/dist/person/person.controller.d.ts +33 -8
  25. package/dist/person/person.controller.d.ts.map +1 -1
  26. package/dist/person/person.controller.js +19 -3
  27. package/dist/person/person.controller.js.map +1 -1
  28. package/dist/person/person.service.d.ts +59 -10
  29. package/dist/person/person.service.d.ts.map +1 -1
  30. package/dist/person/person.service.js +710 -107
  31. package/dist/person/person.service.js.map +1 -1
  32. package/dist/person-relation-type/person-relation-type.controller.d.ts +13 -9
  33. package/dist/person-relation-type/person-relation-type.controller.d.ts.map +1 -1
  34. package/dist/person-relation-type/person-relation-type.service.d.ts +16 -20
  35. package/dist/person-relation-type/person-relation-type.service.d.ts.map +1 -1
  36. package/dist/person-relation-type/person-relation-type.service.js +48 -41
  37. package/dist/person-relation-type/person-relation-type.service.js.map +1 -1
  38. package/hedhog/data/menu.yaml +2 -16
  39. package/hedhog/data/route.yaml +2 -21
  40. package/hedhog/data/setting_group.yaml +21 -0
  41. package/hedhog/frontend/app/person/_components/delete-person-dialog.tsx.ejs +59 -0
  42. package/hedhog/frontend/app/person/_components/person-field-with-create.tsx.ejs +831 -0
  43. package/hedhog/frontend/app/person/_components/person-form-sheet.tsx.ejs +1997 -0
  44. package/hedhog/frontend/app/person/_components/person-types.ts.ejs +115 -0
  45. package/hedhog/frontend/app/person/page.tsx.ejs +1209 -1530
  46. package/hedhog/frontend/messages/en.json +114 -4
  47. package/hedhog/frontend/messages/pt.json +114 -4
  48. package/hedhog/table/person.yaml +7 -0
  49. package/hedhog/table/person_address.yaml +18 -0
  50. package/hedhog/table/person_company.yaml +26 -11
  51. package/hedhog/table/person_individual.yaml +17 -13
  52. package/hedhog/table/person_individual_relation.yaml +39 -0
  53. package/package.json +6 -5
  54. package/src/address-type.enum.ts +9 -0
  55. package/src/contact.module.ts +46 -48
  56. package/src/contact.service.ts +28 -13
  57. package/src/index.ts +6 -13
  58. package/src/language/en.json +13 -6
  59. package/src/language/pt.json +14 -6
  60. package/src/person/dto/create.dto.ts +62 -14
  61. package/src/person/dto/update.dto.ts +147 -75
  62. package/src/person/person.controller.ts +39 -27
  63. package/src/person/person.service.ts +1071 -239
  64. package/src/person-relation-type/person-relation-type.service.ts +84 -76
  65. package/hedhog/data/address_type.yaml +0 -28
  66. package/hedhog/frontend/app/address-type/page.tsx.ejs +0 -480
  67. package/hedhog/query/add-unique-address-type-locale.sql +0 -3
  68. package/hedhog/table/address.yaml +0 -28
  69. package/hedhog/table/address_type.yaml +0 -11
  70. package/hedhog/table/person_relation.yaml +0 -20
  71. package/hedhog/table/person_relation_type.yaml +0 -6
  72. package/src/address-type/address-type.controller.ts +0 -55
  73. package/src/address-type/address-type.enum.ts +0 -9
  74. package/src/address-type/address-type.module.ts +0 -18
  75. package/src/address-type/address-type.service.ts +0 -121
  76. package/src/address-type/dto/create.dto.ts +0 -19
  77. package/src/address-type/dto/update.dto.ts +0 -9
@@ -16,19 +16,34 @@ export class ContactService {
16
16
  private readonly jwtService: JwtService,
17
17
  ) {}
18
18
 
19
- async getPerson(personId: number) {
20
- return this.prismaService.person.findUnique({
21
- where: {
22
- id: personId,
23
- },
24
- include: {
25
- contact: true,
26
- address: true,
27
- document: true,
28
- person_metadata: true,
29
- },
30
- });
31
- }
19
+ async getPerson(personId: number) {
20
+ const person = await this.prismaService.person.findUnique({
21
+ where: {
22
+ id: personId,
23
+ },
24
+ include: {
25
+ contact: true,
26
+ person_address: {
27
+ include: {
28
+ address: true,
29
+ },
30
+ },
31
+ document: true,
32
+ person_metadata: true,
33
+ },
34
+ });
35
+
36
+ if (!person) {
37
+ return null;
38
+ }
39
+
40
+ const { person_address, ...data } = person;
41
+
42
+ return {
43
+ ...data,
44
+ address: person_address.map((item) => item.address),
45
+ };
46
+ }
32
47
 
33
48
  async getPersonOrCreateIfNotExists(
34
49
  type_id: number,
package/src/index.ts CHANGED
@@ -1,14 +1,7 @@
1
- export * from "./contact.module";
2
- export * from "./contact.service";
1
+ export * from './contact.module';
2
+ export * from './contact.service';
3
+
4
+ export * from './address-type.enum';
5
+ export * from './contact-type/contact-type.enum';
6
+ export * from './document-type/document-type.enum';
3
7
 
4
- export * from "./address-type/address-type.enum";
5
-
6
- export * from "./contact-type/contact-type.enum";
7
-
8
- export * from "./document-type/document-type.enum";
9
-
10
- export * from "./address-type/address-type.enum";
11
-
12
- export * from "./contact-type/contact-type.enum";
13
-
14
- export * from "./document-type/document-type.enum";
@@ -7,11 +7,15 @@
7
7
  "documentTypeNotFound": "Document Type not found",
8
8
  "addressTypesNotFound": "Address Types not found",
9
9
  "contactTypesNotFound": "Contact Types not found",
10
- "documentTypesNotFound": "Document Types not found",
11
- "moreThanOnePrimaryContact": "More than one contact of the same type cannot be marked as primary.",
12
- "moreThanOnePrimaryAddress": "More than one address of the same type cannot be marked as primary.",
13
- "moreThanOnePrimaryDocument": "More than one document of the same type cannot be marked as primary.",
14
- "validation": {
10
+ "documentTypesNotFound": "Document Types not found",
11
+ "moreThanOnePrimaryContact": "More than one contact of the same type cannot be marked as primary.",
12
+ "moreThanOnePrimaryAddress": "More than one address of the same type cannot be marked as primary.",
13
+ "moreThanOnePrimaryDocument": "More than one document of the same type cannot be marked as primary.",
14
+ "companyRegistrationDisabled": "Company registration is disabled. Only individual records can be created.",
15
+ "employeeRelationTypeMissing": "Configure the employee relationship type before linking an individual to a company.",
16
+ "employeeRelationSelfReference": "A person cannot be linked as an employee of the same record.",
17
+ "employeeCompanyInvalidTarget": "Only company records can be selected as employer.",
18
+ "validation": {
15
19
  "codeMustBeString": "Code must be a string",
16
20
  "countryCodeMustBeString": "Country code must be a string",
17
21
  "nameMustBeString": "Name must be a string",
@@ -24,10 +28,13 @@
24
28
  "line1MustBeString": "line1 must be a string",
25
29
  "cityMustBeString": "City must be a string",
26
30
  "stateMustBeString": "State must be a string",
27
- "addressTypeIdMustBeInteger": "address_type_id must be an integer",
31
+ "addressTypeMustBeEnum": "address_type must be a valid enum value",
32
+ "line2MustBeString": "line2 must be a string",
33
+ "postalCodeMustBeString": "postal_code must be a string",
28
34
  "documentTypeIdMustBeInteger": "document_type_id must be an integer",
29
35
  "contactsMustBeArray": "Contacts must be an array",
30
36
  "addressesMustBeArray": "Addresses must be an array",
31
37
  "documentsMustBeArray": "Documents must be an array"
32
38
  }
33
39
  }
40
+
@@ -7,11 +7,15 @@
7
7
  "documentTypeNotFound": "Tipo de Documento não encontrado",
8
8
  "addressTypesNotFound": "Tipos de Endereço não encontrados",
9
9
  "contactTypesNotFound": "Tipos de Contato não encontrados",
10
- "documentTypesNotFound": "Tipos de Documento não encontrados",
11
- "moreThanOnePrimaryContact": "Não é permitido mais de um contato do mesmo tipo marcado como principal.",
12
- "moreThanOnePrimaryAddress": "Não é permitido mais de um endereço do mesmo tipo marcado como principal.",
13
- "moreThanOnePrimaryDocument": "Não é permitido mais de um documento do mesmo tipo marcado como principal.",
14
- "validation": {
10
+ "documentTypesNotFound": "Tipos de Documento não encontrados",
11
+ "moreThanOnePrimaryContact": "Não é permitido mais de um contato do mesmo tipo marcado como principal.",
12
+ "moreThanOnePrimaryAddress": "Não é permitido mais de um endereço do mesmo tipo marcado como principal.",
13
+ "moreThanOnePrimaryDocument": "Não é permitido mais de um documento do mesmo tipo marcado como principal.",
14
+ "companyRegistrationDisabled": "O cadastro de empresas esta desabilitado. Apenas pessoas fisicas podem ser cadastradas.",
15
+ "employeeRelationTypeMissing": "Configure o tipo de relacionamento empregado antes de vincular uma pessoa física a uma empresa.",
16
+ "employeeRelationSelfReference": "Uma pessoa não pode ser vinculada como empregada do mesmo cadastro.",
17
+ "employeeCompanyInvalidTarget": "Apenas cadastros do tipo empresa podem ser selecionados como empregador.",
18
+ "validation": {
15
19
  "codeMustBeString": "Código deve ser uma string",
16
20
  "countryCodeMustBeString": "Código do país deve ser uma string",
17
21
  "nameMustBeString": "Nome deve ser uma string",
@@ -24,10 +28,14 @@
24
28
  "line1MustBeString": "line1 deve ser uma string",
25
29
  "cityMustBeString": "Cidade deve ser uma string",
26
30
  "stateMustBeString": "Estado deve ser uma string",
27
- "addressTypeIdMustBeInteger": "address_type_id deve ser um inteiro",
31
+ "addressTypeMustBeEnum": "address_type deve ser um valor de enum valido",
32
+ "line2MustBeString": "line2 deve ser uma string",
33
+ "postalCodeMustBeString": "postal_code deve ser uma string",
28
34
  "documentTypeIdMustBeInteger": "document_type_id deve ser um inteiro",
29
35
  "contactsMustBeArray": "Contatos devem ser um array",
30
36
  "addressesMustBeArray": "Endereços devem ser um array",
31
37
  "documentsMustBeArray": "Documentos devem ser um array"
32
38
  }
33
39
  }
40
+
41
+
@@ -1,23 +1,71 @@
1
- import { getLocaleText } from '@hed-hog/api-locale';
2
- import { IsEnum, IsString } from 'class-validator';
1
+ import { getLocaleText } from '@hed-hog/api-locale';
2
+ import {
3
+ IsDateString,
4
+ IsEnum,
5
+ IsInt,
6
+ IsOptional,
7
+ IsString,
8
+ } from 'class-validator';
3
9
 
4
10
  export enum PersonType {
5
11
  INDIVIDUAL = 'individual',
6
12
  COMPANY = 'company'
7
13
  }
8
14
 
9
- export enum PersonStatus {
10
- ACTIVE = 'active',
11
- INACTIVE = 'inactive'
12
- }
13
-
14
- export class CreateDTO {
15
- @IsString({ message: (args) => getLocaleText('validation.nameMustBeString', args.value) })
16
- name: string;
15
+ export enum PersonStatus {
16
+ ACTIVE = 'active',
17
+ INACTIVE = 'inactive'
18
+ }
19
+
20
+ export enum PersonGender {
21
+ MALE = 'male',
22
+ FEMALE = 'female',
23
+ OTHER = 'other'
24
+ }
25
+
26
+ export class CreateDTO {
27
+ @IsString({ message: (args) => getLocaleText('validation.nameMustBeString', args.value) })
28
+ name: string;
17
29
 
18
30
  @IsEnum(PersonType, { message: (args) => getLocaleText('validation.typeMustBeEnum', args.value) })
19
31
  type: PersonType;
20
-
21
- @IsEnum(PersonStatus, { message: (args) => getLocaleText('validation.statusMustBeEnum', args.value) })
22
- status: PersonStatus = PersonStatus.ACTIVE;
23
- }
32
+
33
+ @IsEnum(PersonStatus, { message: (args) => getLocaleText('validation.statusMustBeEnum', args.value) })
34
+ status: PersonStatus = PersonStatus.ACTIVE;
35
+
36
+ @IsOptional()
37
+ @IsInt({ message: (args) => getLocaleText('validation.idMustBeInteger', args.value) })
38
+ avatar_id?: number | null;
39
+
40
+ @IsOptional()
41
+ @IsDateString({}, { message: (args) => getLocaleText('validation.dateMustBeString', args.value) })
42
+ birth_date?: string | null;
43
+
44
+ @IsOptional()
45
+ @IsEnum(PersonGender, { message: (args) => getLocaleText('validation.typeMustBeEnum', args.value) })
46
+ gender?: PersonGender | null;
47
+
48
+ @IsOptional()
49
+ @IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
50
+ job_title?: string | null;
51
+
52
+ @IsOptional()
53
+ @IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
54
+ trade_name?: string | null;
55
+
56
+ @IsOptional()
57
+ @IsDateString({}, { message: (args) => getLocaleText('validation.dateMustBeString', args.value) })
58
+ foundation_date?: string | null;
59
+
60
+ @IsOptional()
61
+ @IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
62
+ legal_nature?: string | null;
63
+
64
+ @IsOptional()
65
+ @IsString({ message: (args) => getLocaleText('validation.notesMustBeString', args.value) })
66
+ notes?: string | null;
67
+
68
+ @IsOptional()
69
+ @IsInt({ message: (args) => getLocaleText('validation.idMustBeInteger', args.value) })
70
+ employer_company_id?: number | null;
71
+ }
@@ -1,77 +1,149 @@
1
- import { getLocaleText } from '@hed-hog/api-locale';
2
- import { Type } from 'class-transformer';
3
- import { IsArray, IsBoolean, IsInt, IsOptional, IsString, ValidateNested } from 'class-validator';
4
-
5
- export class UpdateAllContactDTO {
6
- @IsOptional()
7
- @IsInt({ message: (args) => getLocaleText('validation.idMustBeInteger', args.value) })
8
- id?: number;
9
-
10
- @IsString({ message: (args) => getLocaleText('validation.valueMustBeString', args.value) })
11
- value: string;
12
-
13
- @IsBoolean({ message: (args) => getLocaleText('validation.isPrimaryMustBeBoolean', args.value) })
14
- is_primary: boolean;
15
-
16
- @IsInt({ message: (args) => getLocaleText('validation.contactTypeIdMustBeInteger', args.value) })
17
- contact_type_id: number;
18
- }
19
-
20
- export class UpdateAllAddressDTO {
21
- @IsOptional()
22
- @IsInt({ message: (args) => getLocaleText('validation.idMustBeInteger', args.value) })
23
- id?: number;
24
-
25
- @IsString({ message: (args) => getLocaleText('validation.line1MustBeString', args.value) })
26
- line1: string;
27
-
28
- @IsString({ message: (args) => getLocaleText('validation.cityMustBeString', args.value) })
29
- city: string;
30
-
31
- @IsString({ message: (args) => getLocaleText('validation.stateMustBeString', args.value) })
32
- state: string;
33
-
34
- @IsBoolean({ message: (args) => getLocaleText('validation.isPrimaryMustBeBoolean', args.value) })
35
- is_primary: boolean;
36
-
37
- @IsInt({ message: (args) => getLocaleText('validation.addressTypeIdMustBeInteger', args.value) })
38
- address_type_id: number;
1
+ import { AddressTypeEnum } from '../../address-type.enum';
2
+ import { PersonGender } from './create.dto';
3
+ import { getLocaleText } from '@hed-hog/api-locale';
4
+ import { Type } from 'class-transformer';
5
+ import {
6
+ IsArray,
7
+ IsBoolean,
8
+ IsDateString,
9
+ IsEnum,
10
+ IsInt,
11
+ IsOptional,
12
+ IsString,
13
+ ValidateNested,
14
+ } from 'class-validator';
15
+
16
+ export class UpdateAllContactDTO {
17
+ @IsOptional()
18
+ @IsInt({ message: (args) => getLocaleText('validation.idMustBeInteger', args.value) })
19
+ id?: number;
20
+
21
+ @IsString({ message: (args) => getLocaleText('validation.valueMustBeString', args.value) })
22
+ value: string;
23
+
24
+ @IsBoolean({ message: (args) => getLocaleText('validation.isPrimaryMustBeBoolean', args.value) })
25
+ is_primary: boolean;
26
+
27
+ @IsInt({ message: (args) => getLocaleText('validation.contactTypeIdMustBeInteger', args.value) })
28
+ contact_type_id: number;
29
+ }
30
+
31
+ export class UpdateAllAddressDTO {
32
+ @IsOptional()
33
+ @IsInt({ message: (args) => getLocaleText('validation.idMustBeInteger', args.value) })
34
+ id?: number;
35
+
36
+ @IsString({ message: (args) => getLocaleText('validation.line1MustBeString', args.value) })
37
+ line1: string;
38
+
39
+ @IsOptional()
40
+ @IsString({ message: (args) => getLocaleText('validation.line2MustBeString', args.value) })
41
+ line2?: string;
42
+
43
+ @IsString({ message: (args) => getLocaleText('validation.cityMustBeString', args.value) })
44
+ city: string;
45
+
46
+ @IsString({ message: (args) => getLocaleText('validation.stateMustBeString', args.value) })
47
+ state: string;
48
+
49
+ @IsOptional()
50
+ @IsString({ message: (args) => getLocaleText('validation.countryCodeMustBeString', args.value) })
51
+ country_code?: string;
52
+
53
+ @IsOptional()
54
+ @IsString({ message: (args) => getLocaleText('validation.postalCodeMustBeString', args.value) })
55
+ postal_code?: string;
56
+
57
+ @IsBoolean({ message: (args) => getLocaleText('validation.isPrimaryMustBeBoolean', args.value) })
58
+ is_primary: boolean;
59
+
60
+ @IsEnum(AddressTypeEnum, {
61
+ message: (args) => getLocaleText('validation.addressTypeMustBeEnum', args.value),
62
+ })
63
+ address_type: AddressTypeEnum;
64
+ }
65
+
66
+ export class UpdateAllDocumentDTO {
67
+ @IsOptional()
68
+ @IsInt({ message: (args) => getLocaleText('validation.idMustBeInteger', args.value) })
69
+ id?: number;
70
+
71
+ @IsString({ message: (args) => getLocaleText('validation.valueMustBeString', args.value) })
72
+ value: string;
73
+
74
+ @IsInt({ message: (args) => getLocaleText('validation.documentTypeIdMustBeInteger', args.value) })
75
+ document_type_id: number;
76
+ }
77
+
78
+ export class UpdateAllPersonDTO {
79
+ @IsString({ message: (args) => getLocaleText('validation.nameMustBeString', args.value) })
80
+ name: string;
81
+
82
+ @IsString({ message: (args) => getLocaleText('validation.typeMustBeEnum', args.value) })
83
+ type: string;
84
+
85
+ @IsString({ message: (args) => getLocaleText('validation.statusMustBeEnum', args.value) })
86
+ status: string;
87
+
88
+ @IsOptional()
89
+ @IsInt({ message: (args) => getLocaleText('validation.idMustBeInteger', args.value) })
90
+ avatar_id?: number | null;
91
+
92
+ @IsOptional()
93
+ @IsDateString({}, { message: (args) => getLocaleText('validation.dateMustBeString', args.value) })
94
+ birth_date?: string | null;
95
+
96
+ @IsOptional()
97
+ @IsEnum(PersonGender, { message: (args) => getLocaleText('validation.typeMustBeEnum', args.value) })
98
+ gender?: PersonGender | null;
99
+
100
+ @IsOptional()
101
+ @IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
102
+ job_title?: string | null;
103
+
104
+ @IsOptional()
105
+ @IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
106
+ trade_name?: string | null;
107
+
108
+ @IsOptional()
109
+ @IsDateString({}, { message: (args) => getLocaleText('validation.dateMustBeString', args.value) })
110
+ foundation_date?: string | null;
111
+
112
+ @IsOptional()
113
+ @IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
114
+ legal_nature?: string | null;
115
+
116
+ @IsOptional()
117
+ @IsString({ message: (args) => getLocaleText('validation.notesMustBeString', args.value) })
118
+ notes?: string | null;
119
+
120
+ @IsOptional()
121
+ @IsInt({ message: (args) => getLocaleText('validation.idMustBeInteger', args.value) })
122
+ employer_company_id?: number | null;
123
+
124
+ @IsOptional()
125
+ @IsInt({ message: (args) => getLocaleText('validation.idMustBeInteger', args.value) })
126
+ headquarter_id?: number | null;
127
+
128
+ @IsOptional()
129
+ @IsArray({ message: (args) => getLocaleText('validation.contactsMustBeArray', args.value) })
130
+ @Type(() => Number)
131
+ @IsInt({ each: true, message: (args) => getLocaleText('validation.idMustBeInteger', args.value) })
132
+ branch_ids?: number[];
133
+
134
+ @IsArray({ message: (args) => getLocaleText('validation.contactsMustBeArray', args.value) })
135
+ @ValidateNested({ each: true })
136
+ @Type(() => UpdateAllContactDTO)
137
+ contacts: UpdateAllContactDTO[];
138
+
139
+ @IsArray({ message: (args) => getLocaleText('validation.addressesMustBeArray', args.value) })
140
+ @ValidateNested({ each: true })
141
+ @Type(() => UpdateAllAddressDTO)
142
+ addresses: UpdateAllAddressDTO[];
143
+
144
+ @IsArray({ message: (args) => getLocaleText('validation.documentsMustBeArray', args.value) })
145
+ @ValidateNested({ each: true })
146
+ @Type(() => UpdateAllDocumentDTO)
147
+ documents: UpdateAllDocumentDTO[];
39
148
  }
40
149
 
41
- export class UpdateAllDocumentDTO {
42
- @IsOptional()
43
- @IsInt({ message: (args) => getLocaleText('validation.idMustBeInteger', args.value) })
44
- id?: number;
45
-
46
- @IsString({ message: (args) => getLocaleText('validation.valueMustBeString', args.value) })
47
- value: string;
48
-
49
- @IsInt({ message: (args) => getLocaleText('validation.documentTypeIdMustBeInteger', args.value) })
50
- document_type_id: number;
51
- }
52
-
53
- export class UpdateAllPersonDTO {
54
- @IsString({ message: (args) => getLocaleText('validation.nameMustBeString', args.value) })
55
- name: string;
56
-
57
- @IsString({ message: (args) => getLocaleText('validation.typeMustBeEnum', args.value) })
58
- type: string;
59
-
60
- @IsString({ message: (args) => getLocaleText('validation.statusMustBeEnum', args.value) })
61
- status: string;
62
-
63
- @IsArray({ message: (args) => getLocaleText('validation.contactsMustBeArray', args.value) })
64
- @ValidateNested({ each: true })
65
- @Type(() => UpdateAllContactDTO)
66
- contacts: UpdateAllContactDTO[];
67
-
68
- @IsArray({ message: (args) => getLocaleText('validation.addressesMustBeArray', args.value) })
69
- @ValidateNested({ each: true })
70
- @Type(() => UpdateAllAddressDTO)
71
- addresses: UpdateAllAddressDTO[];
72
-
73
- @IsArray({ message: (args) => getLocaleText('validation.documentsMustBeArray', args.value) })
74
- @ValidateNested({ each: true })
75
- @Type(() => UpdateAllDocumentDTO)
76
- documents: UpdateAllDocumentDTO[];
77
- }
@@ -1,22 +1,24 @@
1
- import { DeleteDTO, Role } from '@hed-hog/api';
2
- import { Locale } from '@hed-hog/api-locale';
3
- import { Pagination } from '@hed-hog/api-pagination';
4
- import {
5
- Body,
6
- Controller,
1
+ import { DeleteDTO, Public, Role } from '@hed-hog/api';
2
+ import { Locale } from '@hed-hog/api-locale';
3
+ import { Pagination } from '@hed-hog/api-pagination';
4
+ import {
5
+ Body,
6
+ Controller,
7
7
  Delete,
8
8
  Get,
9
9
  Inject,
10
10
  Param,
11
- ParseIntPipe,
12
- Patch,
13
- Post,
14
- Query,
15
- forwardRef
16
- } from '@nestjs/common';
17
- import { CreateDTO } from './dto/create.dto';
18
- import { UpdateAllPersonDTO } from './dto/update.dto';
19
- import { PersonService } from './person.service';
11
+ ParseIntPipe,
12
+ Patch,
13
+ Post,
14
+ Query,
15
+ Res,
16
+ forwardRef
17
+ } from '@nestjs/common';
18
+ import { Response } from 'express';
19
+ import { CreateDTO } from './dto/create.dto';
20
+ import { UpdateAllPersonDTO } from './dto/update.dto';
21
+ import { PersonService } from './person.service';
20
22
 
21
23
  @Role()
22
24
  @Controller('person')
@@ -32,19 +34,29 @@ export class PersonController {
32
34
  }
33
35
 
34
36
  @Get()
35
- async list(@Pagination() paginationParams, @Query() filters) {
36
- return this.personService.list({ ...paginationParams, ...filters });
37
- }
38
-
39
- @Get(':id')
40
- async get(@Param('id', ParseIntPipe) id: number, @Locale() locale: string) {
41
- return this.personService.get(locale, id);
42
- }
37
+ async list(@Pagination() paginationParams, @Query() filters) {
38
+ return this.personService.list({ ...paginationParams, ...filters });
39
+ }
40
+
41
+ @Public()
42
+ @Get('avatar/:id')
43
+ async openAvatar(
44
+ @Param('id', ParseIntPipe) id: number,
45
+ @Res() res: Response,
46
+ @Locale() locale: string,
47
+ ) {
48
+ return this.personService.openPublicAvatar(locale, id, res);
49
+ }
50
+
51
+ @Get(':id')
52
+ async get(@Param('id', ParseIntPipe) id: number, @Locale() locale: string) {
53
+ return this.personService.get(locale, id);
54
+ }
43
55
 
44
- @Post()
45
- async create(@Body() data: CreateDTO) {
46
- return this.personService.create(data);
47
- }
56
+ @Post()
57
+ async create(@Body() data: CreateDTO, @Locale() locale: string) {
58
+ return this.personService.create(data, locale);
59
+ }
48
60
 
49
61
  @Patch(':id')
50
62
  async update(