emilsoftware-utilities 1.6.0 → 1.6.1-dev.2
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/AccessiModule.js +16 -3
- package/dist/accessi-module/Dtos/FiltriUtente.d.ts +5 -0
- package/dist/accessi-module/Dtos/FiltriUtente.js +8 -0
- package/dist/accessi-module/Services/FiltriService/FiltriService.js +1 -1
- package/dist/accessi-module/Services/PermissionService/PermissionService.js +8 -3
- package/dist/accessi-module/Services/UserService/UserService.d.ts +1 -1
- package/dist/accessi-module/Services/UserService/UserService.js +31 -9
- package/dist/emilsoftware-utilities-1.6.1-dev.2.tgz +0 -0
- package/package.json +4 -4
- package/dist/emilsoftware-utilities-1.6.0.tgz +0 -0
|
@@ -32,9 +32,16 @@ let AccessiModule = AccessiModule_1 = class AccessiModule {
|
|
|
32
32
|
UserService_1.UserService,
|
|
33
33
|
EmailService_1.EmailService,
|
|
34
34
|
PermissionService_1.PermissionService,
|
|
35
|
-
FiltriService_1.FiltriService
|
|
35
|
+
FiltriService_1.FiltriService,
|
|
36
|
+
],
|
|
37
|
+
exports: [
|
|
38
|
+
'ACCESSI_OPTIONS',
|
|
39
|
+
AuthService_1.AuthService,
|
|
40
|
+
UserService_1.UserService,
|
|
41
|
+
EmailService_1.EmailService,
|
|
42
|
+
PermissionService_1.PermissionService,
|
|
43
|
+
FiltriService_1.FiltriService,
|
|
36
44
|
],
|
|
37
|
-
exports: ['ACCESSI_OPTIONS', AuthService_1.AuthService, UserService_1.UserService, EmailService_1.EmailService, PermissionService_1.PermissionService, FiltriService_1.FiltriService],
|
|
38
45
|
};
|
|
39
46
|
}
|
|
40
47
|
};
|
|
@@ -42,7 +49,13 @@ exports.AccessiModule = AccessiModule;
|
|
|
42
49
|
exports.AccessiModule = AccessiModule = AccessiModule_1 = __decorate([
|
|
43
50
|
(0, common_1.Global)(),
|
|
44
51
|
(0, common_1.Module)({
|
|
45
|
-
controllers: [
|
|
52
|
+
controllers: [
|
|
53
|
+
EmailController_1.EmailController,
|
|
54
|
+
AuthController_1.AuthController,
|
|
55
|
+
PermissionController_1.PermissionController,
|
|
56
|
+
UserController_1.UserController,
|
|
57
|
+
FiltriController_1.FiltriController,
|
|
58
|
+
],
|
|
46
59
|
providers: [AuthService_1.AuthService, UserService_1.UserService, EmailService_1.EmailService, PermissionService_1.PermissionService, FiltriService_1.FiltriService],
|
|
47
60
|
exports: [AuthService_1.AuthService, UserService_1.UserService, EmailService_1.EmailService, PermissionService_1.PermissionService, FiltriService_1.FiltriService],
|
|
48
61
|
})
|
|
@@ -11,6 +11,7 @@ export declare class FiltriUtente {
|
|
|
11
11
|
tipFil?: number;
|
|
12
12
|
idxPos?: number;
|
|
13
13
|
codDip?: number;
|
|
14
|
+
codVet?: number;
|
|
14
15
|
}
|
|
15
16
|
export declare class GetFiltriUtenteResponse extends BaseResponse {
|
|
16
17
|
Result: FiltriUtente[];
|
|
@@ -59,4 +60,8 @@ export declare const FILTRI_UTENTE_DB_MAPPING: {
|
|
|
59
60
|
readonly dbField: "CODDIP";
|
|
60
61
|
readonly numeric: true;
|
|
61
62
|
};
|
|
63
|
+
readonly codVet: {
|
|
64
|
+
readonly dbField: "CODVET";
|
|
65
|
+
readonly numeric: true;
|
|
66
|
+
};
|
|
62
67
|
};
|
|
@@ -112,6 +112,13 @@ __decorate([
|
|
|
112
112
|
(0, class_validator_1.IsOptional)(),
|
|
113
113
|
__metadata("design:type", Number)
|
|
114
114
|
], FiltriUtente.prototype, "codDip", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
117
|
+
description: 'Codice del vettore',
|
|
118
|
+
example: 12
|
|
119
|
+
}),
|
|
120
|
+
__metadata("design:type", Number)
|
|
121
|
+
], FiltriUtente.prototype, "codVet", void 0);
|
|
115
122
|
class GetFiltriUtenteResponse extends BaseResponse_1.BaseResponse {
|
|
116
123
|
}
|
|
117
124
|
exports.GetFiltriUtenteResponse = GetFiltriUtenteResponse;
|
|
@@ -143,4 +150,5 @@ exports.FILTRI_UTENTE_DB_MAPPING = {
|
|
|
143
150
|
tipFil: { dbField: 'TIPFIL', numeric: true },
|
|
144
151
|
idxPos: { dbField: 'IDXPOS', numeric: true },
|
|
145
152
|
codDip: { dbField: 'CODDIP', numeric: true },
|
|
153
|
+
codVet: { dbField: 'CODVET', numeric: true },
|
|
146
154
|
};
|
|
@@ -52,7 +52,7 @@ let FiltriService = FiltriService_1 = class FiltriService {
|
|
|
52
52
|
try {
|
|
53
53
|
let params = [];
|
|
54
54
|
let getQuery = `SELECT CODUTE AS COD_UTE, PROG AS PROGRESSIVO, NUMREP AS NUM_REP, IDXPERS AS IDX_PERS, CODCLISUPER AS COD_CLI_SUPER, CODAGE AS COD_AGE, CODCLICOL AS COD_CLI_COL,
|
|
55
|
-
CODCLIENTI AS COD_CLIENTI, TIPFIL AS TIP_FIL, CODDIP AS COD_DIP, IDXPOS AS IDX_POS FROM FILTRI `;
|
|
55
|
+
CODCLIENTI AS COD_CLIENTI, TIPFIL AS TIP_FIL, CODDIP AS COD_DIP, IDXPOS AS IDX_POS, CODVET AS COD_VET FROM FILTRI `;
|
|
56
56
|
if (codUte === undefined) {
|
|
57
57
|
this.logger.log('Nessun utente passato, recupero i filtri di tutti gli utenti...');
|
|
58
58
|
}
|
|
@@ -51,11 +51,16 @@ let PermissionService = class PermissionService {
|
|
|
51
51
|
}
|
|
52
52
|
updateOrInsertRole(role_1) {
|
|
53
53
|
return __awaiter(this, arguments, void 0, function* (role, codiceRuolo = null) {
|
|
54
|
+
var _a, _b, _c, _d, _e;
|
|
54
55
|
// creazione nuovo ruolo
|
|
55
56
|
if (!codiceRuolo) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const createRoleQuery = `INSERT INTO RUOLI (DESRUO) VALUES (?)`;
|
|
58
|
+
yield Orm_1.Orm.execute(this.accessiOptions.databaseOptions, createRoleQuery, [role.descrizioneRuolo]);
|
|
59
|
+
const createdRoleResult = yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, 'SELECT FIRST 1 CODRUO FROM RUOLI WHERE DESRUO = ? ORDER BY CODRUO DESC', [role.descrizioneRuolo]);
|
|
60
|
+
codiceRuolo = (_c = (_b = (_a = createdRoleResult === null || createdRoleResult === void 0 ? void 0 : createdRoleResult[0]) === null || _a === void 0 ? void 0 : _a.CODRUO) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : (_e = (_d = createdRoleResult === null || createdRoleResult === void 0 ? void 0 : createdRoleResult[0]) === null || _d === void 0 ? void 0 : _d.codruo) === null || _e === void 0 ? void 0 : _e.toString();
|
|
61
|
+
if (!codiceRuolo) {
|
|
62
|
+
throw new Error('Creazione ruolo non riuscita: impossibile recuperare CODRUO.');
|
|
63
|
+
}
|
|
59
64
|
}
|
|
60
65
|
else
|
|
61
66
|
// aggiornamento ruolo esistente
|
|
@@ -25,7 +25,7 @@ export declare class UserService {
|
|
|
25
25
|
getUserByEmail(email: string): Promise<UserDto | null>;
|
|
26
26
|
insertUserFilters(codiceUtente: number, filterData: RegisterRequest): Promise<void>;
|
|
27
27
|
private executeInTransaction;
|
|
28
|
-
register(registrationData: RegisterRequest): Promise<
|
|
28
|
+
register(registrationData: RegisterRequest): Promise<number>;
|
|
29
29
|
updateUser(codiceUtente: number, user: UserDto): Promise<void>;
|
|
30
30
|
updateUserFilters(codiceUtente: number, user: UserDto): Promise<void>;
|
|
31
31
|
deleteUser(codiceCliente: number): Promise<void>;
|
|
@@ -28,6 +28,7 @@ const Orm_1 = require("../../../Orm");
|
|
|
28
28
|
const Utilities_1 = require("../../../Utilities");
|
|
29
29
|
const StatoRegistrazione_1 = require("../../Dtos/StatoRegistrazione");
|
|
30
30
|
const EmailService_1 = require("../EmailService/EmailService");
|
|
31
|
+
const FiltriUtente_1 = require("../../Dtos/FiltriUtente");
|
|
31
32
|
const PermissionService_1 = require("../PermissionService/PermissionService");
|
|
32
33
|
const FiltriService_1 = require("../FiltriService/FiltriService");
|
|
33
34
|
let UserService = class UserService {
|
|
@@ -130,6 +131,7 @@ let UserService = class UserService {
|
|
|
130
131
|
}
|
|
131
132
|
getUserByEmail(email) {
|
|
132
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
var _a;
|
|
133
135
|
const query = `
|
|
134
136
|
SELECT
|
|
135
137
|
U.CODUTE AS codice_utente,
|
|
@@ -151,19 +153,33 @@ let UserService = class UserService {
|
|
|
151
153
|
WHERE LOWER(U.USRNAME) = ?
|
|
152
154
|
`;
|
|
153
155
|
const utenti = (yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, query, [email]).then((results) => results.map(Utilities_1.RestUtilities.convertKeysToCamelCase)));
|
|
156
|
+
const filtriUtente = yield this.filtriService.getFiltriUser((_a = utenti[0]) === null || _a === void 0 ? void 0 : _a.codiceUtente);
|
|
157
|
+
if (utenti.length <= 0) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
if (utenti.length > 0 && filtriUtente.length > 0) {
|
|
161
|
+
const user = utenti[0];
|
|
162
|
+
const filtro = filtriUtente[0];
|
|
163
|
+
// Type-safe mapping using type assertion
|
|
164
|
+
Object.entries(FiltriUtente_1.FILTRI_UTENTE_DB_MAPPING).forEach(([key]) => {
|
|
165
|
+
if (key in filtro) {
|
|
166
|
+
user[key] = filtro[key];
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
154
170
|
return utenti.length > 0 ? utenti[0] : null;
|
|
155
171
|
});
|
|
156
172
|
}
|
|
157
173
|
// async getUserFilters(codiceUtente: number): Promise<FiltriUtente[]> {
|
|
158
174
|
// const query = `
|
|
159
|
-
// SELECT
|
|
160
|
-
// F.PROG AS progressivo,
|
|
161
|
-
// F.NUMREP AS numero_report,
|
|
175
|
+
// SELECT
|
|
176
|
+
// F.PROG AS progressivo,
|
|
177
|
+
// F.NUMREP AS numero_report,
|
|
162
178
|
// F.IDXPERS AS indice_personale,
|
|
163
|
-
// F.CODCLISUPER AS codice_cliente_super,
|
|
164
|
-
// F.CODAGE AS cod_age,
|
|
179
|
+
// F.CODCLISUPER AS codice_cliente_super,
|
|
180
|
+
// F.CODAGE AS cod_age,
|
|
165
181
|
// F.CODCLICOL AS codice_cliente_collegato,
|
|
166
|
-
// F.CODCLIENTI AS codice_clienti,
|
|
182
|
+
// F.CODCLIENTI AS codice_clienti,
|
|
167
183
|
// F.TIPFIL AS tipo_filtro,
|
|
168
184
|
// F.IDXPOS AS idx_postazione
|
|
169
185
|
// FROM FILTRI F
|
|
@@ -228,14 +244,20 @@ let UserService = class UserService {
|
|
|
228
244
|
}
|
|
229
245
|
register(registrationData) {
|
|
230
246
|
return __awaiter(this, void 0, void 0, function* () {
|
|
247
|
+
var _a, _b, _c;
|
|
231
248
|
try {
|
|
232
249
|
const existingUser = yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, 'SELECT CODUTE FROM UTENTI WHERE USRNAME = ?', [registrationData.email]);
|
|
233
250
|
if (existingUser.length > 0) {
|
|
234
251
|
throw new Error('Questa e-mail è già stata utilizzata!');
|
|
235
252
|
}
|
|
236
|
-
const queryUtenti = `INSERT INTO UTENTI (USRNAME, STAREG) VALUES (?,?)
|
|
253
|
+
const queryUtenti = `INSERT INTO UTENTI (USRNAME, STAREG) VALUES (?,?)`;
|
|
237
254
|
const paramsUtenti = [registrationData.email, StatoRegistrazione_1.StatoRegistrazione.INVIO];
|
|
238
|
-
|
|
255
|
+
yield Orm_1.Orm.execute(this.accessiOptions.databaseOptions, queryUtenti, paramsUtenti);
|
|
256
|
+
const codiceUtenteResult = yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, 'SELECT FIRST 1 CODUTE FROM UTENTI WHERE USRNAME = ? ORDER BY CODUTE DESC', [registrationData.email]);
|
|
257
|
+
const codiceUtente = Number((_b = (_a = codiceUtenteResult === null || codiceUtenteResult === void 0 ? void 0 : codiceUtenteResult[0]) === null || _a === void 0 ? void 0 : _a.CODUTE) !== null && _b !== void 0 ? _b : (_c = codiceUtenteResult === null || codiceUtenteResult === void 0 ? void 0 : codiceUtenteResult[0]) === null || _c === void 0 ? void 0 : _c.codute);
|
|
258
|
+
if (!codiceUtente) {
|
|
259
|
+
throw new Error('Creazione utente non riuscita: impossibile recuperare CODUTE.');
|
|
260
|
+
}
|
|
239
261
|
const utentiConfigFields = ['CODUTE', 'COGNOME', 'NOME'];
|
|
240
262
|
const utentiConfigPlaceholders = ['?', '?', '?'];
|
|
241
263
|
const utentiConfigParams = [codiceUtente, registrationData.cognome, registrationData.nome];
|
|
@@ -253,7 +275,7 @@ let UserService = class UserService {
|
|
|
253
275
|
if (value !== undefined && value !== null) {
|
|
254
276
|
utentiConfigFields.push(dbField);
|
|
255
277
|
utentiConfigPlaceholders.push('?');
|
|
256
|
-
utentiConfigParams.push(value);
|
|
278
|
+
utentiConfigParams.push(Number(value));
|
|
257
279
|
}
|
|
258
280
|
}
|
|
259
281
|
const queryUtentiConfig = `INSERT INTO UTENTI_CONFIG (${utentiConfigFields.join(', ')}) VALUES (${utentiConfigPlaceholders.join(', ')})`;
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emilsoftware-utilities",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1-dev.2",
|
|
4
4
|
"description": "Utilities for EmilSoftware",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/
|
|
21
|
+
"url": "git+https://github.com/Emil-Software/emilsoftware-utilities.git"
|
|
22
22
|
},
|
|
23
23
|
"author": "",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"bugs": {
|
|
26
|
-
"url": "https://github.com/
|
|
26
|
+
"url": "https://github.com/Emil-Software/emilsoftware-utilities/issues"
|
|
27
27
|
},
|
|
28
|
-
"homepage": "https://github.com/
|
|
28
|
+
"homepage": "https://github.com/Emil-Software/emilsoftware-utilities#readme",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@nestjs/common": "^11.0.11",
|
|
31
31
|
"@nestjs/core": "^11.0.11",
|
|
Binary file
|