emilsoftware-utilities 1.4.0-dev.14 → 1.4.0-dev.16
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.
- package/dist/accessi-module/Dtos/RegisterRequest.d.ts +4 -4
- package/dist/accessi-module/Dtos/RegisterRequest.js +7 -7
- package/dist/accessi-module/Dtos/UserDto.d.ts +4 -4
- package/dist/accessi-module/Dtos/UserDto.js +7 -7
- package/dist/accessi-module/Services/UserService/UserService.d.ts +1 -0
- package/dist/accessi-module/Services/UserService/UserService.js +66 -4
- package/dist/emilsoftware-utilities-1.4.0-dev.16.tgz +0 -0
- package/package.json +1 -1
- package/dist/emilsoftware-utilities-1.4.0-dev.14.tgz +0 -0
|
@@ -9,11 +9,11 @@ export declare class RegisterRequest {
|
|
|
9
9
|
permissions?: Permission[];
|
|
10
10
|
numeroReport?: number;
|
|
11
11
|
indicePersonale?: number;
|
|
12
|
-
codiceClienteSuper?:
|
|
13
|
-
codiceAgenzia?:
|
|
14
|
-
codiceClienteCollegato?:
|
|
12
|
+
codiceClienteSuper?: number;
|
|
13
|
+
codiceAgenzia?: number;
|
|
14
|
+
codiceClienteCollegato?: number;
|
|
15
15
|
codiceClienti?: string;
|
|
16
|
-
tipoFiltro?:
|
|
16
|
+
tipoFiltro?: number;
|
|
17
17
|
avatar?: string;
|
|
18
18
|
flagDueFattori?: boolean;
|
|
19
19
|
paginaDefault?: string;
|
|
@@ -83,23 +83,23 @@ __decorate([
|
|
|
83
83
|
__decorate([
|
|
84
84
|
(0, swagger_1.ApiPropertyOptional)({
|
|
85
85
|
description: "Codice del cliente principale (super).",
|
|
86
|
-
example:
|
|
86
|
+
example: 123,
|
|
87
87
|
}),
|
|
88
|
-
__metadata("design:type",
|
|
88
|
+
__metadata("design:type", Number)
|
|
89
89
|
], RegisterRequest.prototype, "codiceClienteSuper", void 0);
|
|
90
90
|
__decorate([
|
|
91
91
|
(0, swagger_1.ApiPropertyOptional)({
|
|
92
92
|
description: "Codice dell'agenzia associata.",
|
|
93
|
-
example:
|
|
93
|
+
example: 123,
|
|
94
94
|
}),
|
|
95
|
-
__metadata("design:type",
|
|
95
|
+
__metadata("design:type", Number)
|
|
96
96
|
], RegisterRequest.prototype, "codiceAgenzia", void 0);
|
|
97
97
|
__decorate([
|
|
98
98
|
(0, swagger_1.ApiPropertyOptional)({
|
|
99
99
|
description: "Codice del cliente collegato.",
|
|
100
|
-
example: "
|
|
100
|
+
example: "123",
|
|
101
101
|
}),
|
|
102
|
-
__metadata("design:type",
|
|
102
|
+
__metadata("design:type", Number)
|
|
103
103
|
], RegisterRequest.prototype, "codiceClienteCollegato", void 0);
|
|
104
104
|
__decorate([
|
|
105
105
|
(0, swagger_1.ApiPropertyOptional)({
|
|
@@ -113,7 +113,7 @@ __decorate([
|
|
|
113
113
|
description: "Tipo di filtro applicato.",
|
|
114
114
|
example: "esclusivo",
|
|
115
115
|
}),
|
|
116
|
-
__metadata("design:type",
|
|
116
|
+
__metadata("design:type", Number)
|
|
117
117
|
], RegisterRequest.prototype, "tipoFiltro", void 0);
|
|
118
118
|
__decorate([
|
|
119
119
|
(0, swagger_1.ApiPropertyOptional)({
|
|
@@ -25,9 +25,9 @@ export declare class UserDto {
|
|
|
25
25
|
prog?: number;
|
|
26
26
|
numRep?: number;
|
|
27
27
|
idxPers?: number;
|
|
28
|
-
codiceClienteSuper?:
|
|
29
|
-
codiceAge?:
|
|
30
|
-
codiceClienteCol?:
|
|
28
|
+
codiceClienteSuper?: number;
|
|
29
|
+
codiceAge?: number;
|
|
30
|
+
codiceClienteCol?: number;
|
|
31
31
|
codiceClienti?: string;
|
|
32
|
-
tipoFil?:
|
|
32
|
+
tipoFil?: number;
|
|
33
33
|
}
|
|
@@ -114,16 +114,16 @@ __decorate([
|
|
|
114
114
|
__metadata("design:type", Number)
|
|
115
115
|
], UserDto.prototype, "idxPers", void 0);
|
|
116
116
|
__decorate([
|
|
117
|
-
(0, swagger_1.ApiPropertyOptional)({ description: "Codice cliente super.", example:
|
|
118
|
-
__metadata("design:type",
|
|
117
|
+
(0, swagger_1.ApiPropertyOptional)({ description: "Codice cliente super.", example: 123 }),
|
|
118
|
+
__metadata("design:type", Number)
|
|
119
119
|
], UserDto.prototype, "codiceClienteSuper", void 0);
|
|
120
120
|
__decorate([
|
|
121
|
-
(0, swagger_1.ApiPropertyOptional)({ description: "Codice agente.", example:
|
|
122
|
-
__metadata("design:type",
|
|
121
|
+
(0, swagger_1.ApiPropertyOptional)({ description: "Codice agente.", example: 123 }),
|
|
122
|
+
__metadata("design:type", Number)
|
|
123
123
|
], UserDto.prototype, "codiceAge", void 0);
|
|
124
124
|
__decorate([
|
|
125
|
-
(0, swagger_1.ApiPropertyOptional)({ description: "Codice cliente collettivo.", example:
|
|
126
|
-
__metadata("design:type",
|
|
125
|
+
(0, swagger_1.ApiPropertyOptional)({ description: "Codice cliente collettivo.", example: 123 }),
|
|
126
|
+
__metadata("design:type", Number)
|
|
127
127
|
], UserDto.prototype, "codiceClienteCol", void 0);
|
|
128
128
|
__decorate([
|
|
129
129
|
(0, swagger_1.ApiPropertyOptional)({ description: "Codici multipli clienti.", example: "CLI001, CLI002" }),
|
|
@@ -131,5 +131,5 @@ __decorate([
|
|
|
131
131
|
], UserDto.prototype, "codiceClienti", void 0);
|
|
132
132
|
__decorate([
|
|
133
133
|
(0, swagger_1.ApiPropertyOptional)({ description: "Tipo di filiale.", example: "HQ" }),
|
|
134
|
-
__metadata("design:type",
|
|
134
|
+
__metadata("design:type", Number)
|
|
135
135
|
], UserDto.prototype, "tipoFil", void 0);
|
|
@@ -27,6 +27,7 @@ export declare class UserService {
|
|
|
27
27
|
private executeInTransaction;
|
|
28
28
|
register(registrationData: RegisterRequest): Promise<string>;
|
|
29
29
|
updateUser(codiceUtente: number, user: UserDto): Promise<void>;
|
|
30
|
+
updateUserFilters(codiceUtente: number, user: UserDto): Promise<void>;
|
|
30
31
|
deleteUser(codiceCliente: number): Promise<void>;
|
|
31
32
|
setStato(codiceCliente: number, statoRegistrazione: StatoRegistrazione): Promise<void>;
|
|
32
33
|
setGdpr(codiceUtente: number): Promise<any>;
|
|
@@ -178,9 +178,9 @@ let UserService = class UserService {
|
|
|
178
178
|
const fieldMapping = {
|
|
179
179
|
numeroReport: { dbField: 'NUMREP', type: 'number' },
|
|
180
180
|
indicePersonale: { dbField: 'IDXPERS', type: 'number' },
|
|
181
|
-
codiceClienteSuper: { dbField: 'CODCLISUPER', type: '
|
|
182
|
-
codiceAgenzia: { dbField: 'CODAGE', type: '
|
|
183
|
-
codiceClienteCollegato: { dbField: 'CODCLICOL', type: '
|
|
181
|
+
codiceClienteSuper: { dbField: 'CODCLISUPER', type: 'number' },
|
|
182
|
+
codiceAgenzia: { dbField: 'CODAGE', type: 'number' },
|
|
183
|
+
codiceClienteCollegato: { dbField: 'CODCLICOL', type: 'number' },
|
|
184
184
|
codiceClienti: { dbField: 'CODCLIENTI', type: 'string' },
|
|
185
185
|
tipoFiltro: { dbField: 'TIPFIL', type: 'string' },
|
|
186
186
|
};
|
|
@@ -346,13 +346,75 @@ let UserService = class UserService {
|
|
|
346
346
|
if (!!user.permissions && user.permissions.length > 0) {
|
|
347
347
|
yield this.permissionService.assignPermissionsToUser(codiceUtente, user.permissions);
|
|
348
348
|
}
|
|
349
|
-
yield this.
|
|
349
|
+
yield this.updateUserFilters(codiceUtente, user);
|
|
350
350
|
}
|
|
351
351
|
catch (error) {
|
|
352
352
|
throw error;
|
|
353
353
|
}
|
|
354
354
|
});
|
|
355
355
|
}
|
|
356
|
+
updateUserFilters(codiceUtente, user) {
|
|
357
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
358
|
+
try {
|
|
359
|
+
if (!codiceUtente || codiceUtente <= 0) {
|
|
360
|
+
throw new Error('Codice utente non valido');
|
|
361
|
+
}
|
|
362
|
+
const fieldMapping = {
|
|
363
|
+
numRep: { dbField: 'NUMREP', type: 'number' },
|
|
364
|
+
idxPers: { dbField: 'IDXPERS', type: 'number' },
|
|
365
|
+
codCliSuper: { dbField: 'CODCLISUPER', type: 'number' },
|
|
366
|
+
codAge: { dbField: 'CODAGE', type: 'number' },
|
|
367
|
+
codCliCol: { dbField: 'CODCLICOL', type: 'number' },
|
|
368
|
+
codiceClienti: { dbField: 'CODCLIENTI', type: 'string' },
|
|
369
|
+
tipFil: { dbField: 'TIPFIL', type: 'string' },
|
|
370
|
+
};
|
|
371
|
+
const fieldsToUpdate = Object.entries(fieldMapping)
|
|
372
|
+
.filter(([tsField]) => {
|
|
373
|
+
const value = user[tsField];
|
|
374
|
+
return value !== undefined && value !== null && value !== '';
|
|
375
|
+
})
|
|
376
|
+
.map(([tsField, config]) => {
|
|
377
|
+
const value = user[tsField];
|
|
378
|
+
if (config.type === 'number' && typeof value !== 'number') {
|
|
379
|
+
throw new Error(`Il campo ${tsField} deve essere un numero`);
|
|
380
|
+
}
|
|
381
|
+
if (config.type === 'string' && typeof value !== 'string') {
|
|
382
|
+
throw new Error(`Il campo ${tsField} deve essere una stringa`);
|
|
383
|
+
}
|
|
384
|
+
return { tsField, dbField: config.dbField, value };
|
|
385
|
+
});
|
|
386
|
+
if (fieldsToUpdate.length === 0) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
yield this.executeInTransaction(() => __awaiter(this, void 0, void 0, function* () {
|
|
390
|
+
// Prima verifichiamo se esiste il record
|
|
391
|
+
const checkQuery = `SELECT COUNT(*) as CNT FROM FILTRI WHERE CODUTE = ?`;
|
|
392
|
+
const existingRecord = yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, checkQuery, [
|
|
393
|
+
codiceUtente,
|
|
394
|
+
]);
|
|
395
|
+
const exists = existingRecord[0].CNT > 0;
|
|
396
|
+
if (exists) {
|
|
397
|
+
// Se esiste, facciamo l'UPDATE
|
|
398
|
+
const updates = fieldsToUpdate.map((f) => `${f.dbField} = ?`).join(', ');
|
|
399
|
+
const values = [...fieldsToUpdate.map((f) => f.value), codiceUtente];
|
|
400
|
+
const updateQuery = `UPDATE FILTRI SET ${updates} WHERE CODUTE = ?`;
|
|
401
|
+
yield Orm_1.Orm.execute(this.accessiOptions.databaseOptions, updateQuery, values);
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
// Se non esiste, facciamo l'INSERT
|
|
405
|
+
const dbFields = ['CODUTE', ...fieldsToUpdate.map((f) => f.dbField)];
|
|
406
|
+
const placeholders = dbFields.map(() => '?');
|
|
407
|
+
const insertValues = [codiceUtente, ...fieldsToUpdate.map((f) => f.value)];
|
|
408
|
+
const insertQuery = `INSERT INTO FILTRI (${dbFields.join(', ')}) VALUES (${placeholders.join(', ')})`;
|
|
409
|
+
yield Orm_1.Orm.execute(this.accessiOptions.databaseOptions, insertQuery, insertValues);
|
|
410
|
+
}
|
|
411
|
+
}));
|
|
412
|
+
}
|
|
413
|
+
catch (error) {
|
|
414
|
+
throw new Error(`Errore durante l'aggiornamento dei filtri per utente ${codiceUtente}: ${error.message}`);
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
}
|
|
356
418
|
deleteUser(codiceCliente) {
|
|
357
419
|
return __awaiter(this, void 0, void 0, function* () {
|
|
358
420
|
try {
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|