rez_core 1.0.61 → 1.0.63
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/.idea/250218_nodejs_core.iml +12 -0
- package/.idea/codeStyles/Project.xml +59 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/dataSources.xml +12 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +6 -0
- package/dist/module/auth/guards/role.guard.js +3 -3
- package/dist/module/enterprise/entity/enterprise.entity.d.ts +7 -7
- package/dist/module/enterprise/entity/enterprise.entity.js +7 -7
- package/dist/module/enterprise/entity/enterprise.entity.js.map +1 -1
- package/dist/module/enterprise/repository/enterprise.repository.d.ts +8 -0
- package/dist/module/enterprise/repository/enterprise.repository.js +48 -0
- package/dist/module/enterprise/repository/enterprise.repository.js.map +1 -0
- package/dist/module/enterprise/service/enterprise.service.d.ts +8 -0
- package/dist/module/enterprise/service/enterprise.service.js +31 -0
- package/dist/module/enterprise/service/enterprise.service.js.map +1 -0
- package/dist/module/listmaster/controller/list-master.controller.d.ts +1 -1
- package/dist/module/listmaster/controller/list-master.controller.js +3 -4
- package/dist/module/listmaster/controller/list-master.controller.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.d.ts +4 -2
- package/dist/module/listmaster/service/list-master.service.js +16 -14
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/meta/controller/view-master.controller.d.ts +7 -0
- package/dist/module/meta/controller/view-master.controller.js +62 -0
- package/dist/module/meta/controller/view-master.controller.js.map +1 -0
- package/dist/module/meta/entity/view-master.entity.d.ts +2 -0
- package/dist/module/meta/entity/view-master.entity.js +8 -0
- package/dist/module/meta/entity/view-master.entity.js.map +1 -1
- package/dist/module/meta/entity.module.js +4 -1
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/repository/view-master.repository.d.ts +7 -0
- package/dist/module/meta/repository/view-master.repository.js +38 -0
- package/dist/module/meta/repository/view-master.repository.js.map +1 -0
- package/dist/module/meta/service/entity-list.service.d.ts +1 -1
- package/dist/module/meta/service/entity-list.service.js.map +1 -1
- package/dist/module/meta/service/entity-master.service.d.ts +1 -1
- package/dist/module/meta/service/entity-master.service.js +11 -6
- package/dist/module/meta/service/entity-master.service.js.map +1 -1
- package/dist/module/meta/service/view-master.service.d.ts +13 -2
- package/dist/module/meta/service/view-master.service.js +41 -22
- package/dist/module/meta/service/view-master.service.js.map +1 -1
- package/dist/module/user/entity/role.entity.d.ts +1 -0
- package/dist/module/user/entity/role.entity.js +5 -0
- package/dist/module/user/entity/role.entity.js.map +1 -1
- package/dist/module/user/repository/role.repository.d.ts +2 -35
- package/dist/module/user/repository/role.repository.js +2 -95
- package/dist/module/user/repository/role.repository.js.map +1 -1
- package/dist/module/user/service/role.service.d.ts +5 -32
- package/dist/module/user/service/role.service.js +71 -24
- package/dist/module/user/service/role.service.js.map +1 -1
- package/dist/module/user/service/user.service.js +2 -1
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/module/user/user.module.js +8 -3
- package/dist/module/user/user.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/app.controller.ts +12 -12
- package/src/app.service.ts +8 -8
- package/src/module/auth/guards/jwt.guard.ts +22 -22
- package/src/module/auth/guards/role.guard.ts +68 -68
- package/src/module/auth/services/jwt.service.ts +11 -11
- package/src/module/auth/strategies/local.strategy.ts +13 -13
- package/src/module/dev/dev.module.ts +12 -12
- package/src/module/dev/service/dev.service.ts +7 -7
- package/src/module/enterprise/entity/enterprise.entity.ts +7 -7
- package/src/module/enterprise/entity/organization.entity.ts +80 -80
- package/src/module/enterprise/repository/enterprise.repository.ts +31 -0
- package/src/module/enterprise/service/enterprise.service.ts +16 -0
- package/src/module/listmaster/controller/list-master.controller.ts +2 -2
- package/src/module/listmaster/service/list-master.service.ts +18 -15
- package/src/module/meta/controller/view-master.controller.ts +48 -0
- package/src/module/meta/dto/entity-list-data.dto.ts +6 -6
- package/src/module/meta/entity/preference.entity.ts +65 -65
- package/src/module/meta/entity/view-master.entity.ts +6 -0
- package/src/module/meta/entity.module.ts +4 -1
- package/src/module/meta/repository/preference.repository.ts +20 -20
- package/src/module/meta/repository/view-master.repository.ts +24 -0
- package/src/module/meta/service/entity-list.service.ts +2 -2
- package/src/module/meta/service/entity-master.service.ts +15 -11
- package/src/module/meta/service/view-master.service.ts +51 -28
- package/src/module/module/controller/menu.controller.ts +15 -15
- package/src/module/module/entity/module-access.entity.ts +22 -22
- package/src/module/user/controller/user.controller.ts +28 -28
- package/src/module/user/dto/update-user.dto.ts +4 -4
- package/src/module/user/entity/role.entity.ts +4 -0
- package/src/module/user/entity/user-session.entity.ts +61 -61
- package/src/module/user/repository/role.repository.ts +2 -142
- package/src/module/user/repository/userSession.repository.ts +33 -33
- package/src/module/user/service/role.service.ts +92 -42
- package/src/module/user/service/user.service.ts +6 -3
- package/src/module/user/user.module.ts +8 -3
- package/src/utils/service/encryptUtil.service.ts +97 -97
- package/src/utils/service/excelUtil.service.ts +15 -15
- package/src/utils/service/reflection-helper.service.ts +53 -53
- package/dist/module/user/controller/role.controller.d.ts +0 -41
- package/dist/module/user/controller/role.controller.js +0 -63
- package/dist/module/user/controller/role.controller.js.map +0 -1
- package/src/module/user/controller/role.controller.ts +0 -55
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
|
2
|
-
import * as crypto from 'crypto';
|
|
3
|
-
|
|
4
|
-
const CryptoJS = require('crypto-js');
|
|
5
|
-
const encryptionType = 'aes-256-cbc';
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class EncryptUtilService {
|
|
9
|
-
constructor() {}
|
|
10
|
-
|
|
11
|
-
static encryptGCM(data: any, Datakey: string, Dataiv: string) {
|
|
12
|
-
try {
|
|
13
|
-
const cipher = crypto.createCipheriv('aes-256-gcm', Datakey, Dataiv);
|
|
14
|
-
let encrypted = Buffer.concat([
|
|
15
|
-
cipher.update(data, 'utf8'),
|
|
16
|
-
cipher.final(),
|
|
17
|
-
]);
|
|
18
|
-
const tag = cipher.getAuthTag();
|
|
19
|
-
return Buffer.concat([encrypted, tag]).toString('base64');
|
|
20
|
-
} catch (error) {
|
|
21
|
-
throw new InternalServerErrorException('Encryption process failed');
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static decryptGCM(data: any, Datakey: any, Dataiv: any) {
|
|
26
|
-
try {
|
|
27
|
-
data = Buffer.from(data, 'base64');
|
|
28
|
-
const decipher = crypto.createDecipheriv('aes-256-gcm', Datakey, Dataiv);
|
|
29
|
-
const tag = data.slice(data.length - 16);
|
|
30
|
-
decipher.setAuthTag(tag);
|
|
31
|
-
data = data.slice(0, data.length - 16);
|
|
32
|
-
let decrypted = decipher.update(data, 'utf8') + decipher.final('utf8');
|
|
33
|
-
return decrypted;
|
|
34
|
-
} catch (error) {
|
|
35
|
-
throw new InternalServerErrorException('Encryption process failed');
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static encryptCBC(data: any, Datakey: any, Dataiv: any) {
|
|
40
|
-
let encryptedRequest;
|
|
41
|
-
try {
|
|
42
|
-
let cipher = CryptoJS.AES.encrypt(data, Datakey, {
|
|
43
|
-
iv: Dataiv,
|
|
44
|
-
mode: CryptoJS.mode.CBC,
|
|
45
|
-
});
|
|
46
|
-
encryptedRequest = cipher.toString();
|
|
47
|
-
} catch (error) {
|
|
48
|
-
console.log(error);
|
|
49
|
-
throw new InternalServerErrorException('Encryption process failed');
|
|
50
|
-
}
|
|
51
|
-
return encryptedRequest;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static decryptCBC(data: any, Datakey: any, Dataiv: any) {
|
|
55
|
-
let decryptRequest;
|
|
56
|
-
try {
|
|
57
|
-
let cipher = CryptoJS.AES.decrypt(data, Datakey, {
|
|
58
|
-
iv: Dataiv,
|
|
59
|
-
mode: CryptoJS.mode.CBC,
|
|
60
|
-
});
|
|
61
|
-
decryptRequest = cipher.toString(CryptoJS.enc.Utf8);
|
|
62
|
-
} catch (error) {
|
|
63
|
-
throw new InternalServerErrorException('Encryption process failed');
|
|
64
|
-
}
|
|
65
|
-
return decryptRequest;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
static encryptRequest(data: any, Datakey: any, Dataiv: any, type?: any) {
|
|
69
|
-
try {
|
|
70
|
-
switch (type) {
|
|
71
|
-
case 'GCM':
|
|
72
|
-
return this.encryptGCM(data, Datakey, Dataiv);
|
|
73
|
-
case 'CBC':
|
|
74
|
-
return this.encryptCBC(data, Datakey, Dataiv);
|
|
75
|
-
default:
|
|
76
|
-
return this.encryptCBC(data, Datakey, Dataiv);
|
|
77
|
-
}
|
|
78
|
-
} catch (error) {
|
|
79
|
-
throw new InternalServerErrorException('Encryption process failed');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
static decryptRequest(data: any, Datakey: any, Dataiv: any, type?: any) {
|
|
84
|
-
try {
|
|
85
|
-
switch (type) {
|
|
86
|
-
case 'GCM':
|
|
87
|
-
return this.decryptGCM(data, Datakey, Dataiv);
|
|
88
|
-
case 'CBC':
|
|
89
|
-
return this.decryptCBC(data, Datakey, Dataiv);
|
|
90
|
-
default:
|
|
91
|
-
return this.decryptCBC(data, Datakey, Dataiv);
|
|
92
|
-
}
|
|
93
|
-
} catch (error) {
|
|
94
|
-
throw new InternalServerErrorException('Encryption process failed');
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
1
|
+
import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
|
2
|
+
import * as crypto from 'crypto';
|
|
3
|
+
|
|
4
|
+
const CryptoJS = require('crypto-js');
|
|
5
|
+
const encryptionType = 'aes-256-cbc';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class EncryptUtilService {
|
|
9
|
+
constructor() {}
|
|
10
|
+
|
|
11
|
+
static encryptGCM(data: any, Datakey: string, Dataiv: string) {
|
|
12
|
+
try {
|
|
13
|
+
const cipher = crypto.createCipheriv('aes-256-gcm', Datakey, Dataiv);
|
|
14
|
+
let encrypted = Buffer.concat([
|
|
15
|
+
cipher.update(data, 'utf8'),
|
|
16
|
+
cipher.final(),
|
|
17
|
+
]);
|
|
18
|
+
const tag = cipher.getAuthTag();
|
|
19
|
+
return Buffer.concat([encrypted, tag]).toString('base64');
|
|
20
|
+
} catch (error) {
|
|
21
|
+
throw new InternalServerErrorException('Encryption process failed');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static decryptGCM(data: any, Datakey: any, Dataiv: any) {
|
|
26
|
+
try {
|
|
27
|
+
data = Buffer.from(data, 'base64');
|
|
28
|
+
const decipher = crypto.createDecipheriv('aes-256-gcm', Datakey, Dataiv);
|
|
29
|
+
const tag = data.slice(data.length - 16);
|
|
30
|
+
decipher.setAuthTag(tag);
|
|
31
|
+
data = data.slice(0, data.length - 16);
|
|
32
|
+
let decrypted = decipher.update(data, 'utf8') + decipher.final('utf8');
|
|
33
|
+
return decrypted;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
throw new InternalServerErrorException('Encryption process failed');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static encryptCBC(data: any, Datakey: any, Dataiv: any) {
|
|
40
|
+
let encryptedRequest;
|
|
41
|
+
try {
|
|
42
|
+
let cipher = CryptoJS.AES.encrypt(data, Datakey, {
|
|
43
|
+
iv: Dataiv,
|
|
44
|
+
mode: CryptoJS.mode.CBC,
|
|
45
|
+
});
|
|
46
|
+
encryptedRequest = cipher.toString();
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.log(error);
|
|
49
|
+
throw new InternalServerErrorException('Encryption process failed');
|
|
50
|
+
}
|
|
51
|
+
return encryptedRequest;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static decryptCBC(data: any, Datakey: any, Dataiv: any) {
|
|
55
|
+
let decryptRequest;
|
|
56
|
+
try {
|
|
57
|
+
let cipher = CryptoJS.AES.decrypt(data, Datakey, {
|
|
58
|
+
iv: Dataiv,
|
|
59
|
+
mode: CryptoJS.mode.CBC,
|
|
60
|
+
});
|
|
61
|
+
decryptRequest = cipher.toString(CryptoJS.enc.Utf8);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
throw new InternalServerErrorException('Encryption process failed');
|
|
64
|
+
}
|
|
65
|
+
return decryptRequest;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static encryptRequest(data: any, Datakey: any, Dataiv: any, type?: any) {
|
|
69
|
+
try {
|
|
70
|
+
switch (type) {
|
|
71
|
+
case 'GCM':
|
|
72
|
+
return this.encryptGCM(data, Datakey, Dataiv);
|
|
73
|
+
case 'CBC':
|
|
74
|
+
return this.encryptCBC(data, Datakey, Dataiv);
|
|
75
|
+
default:
|
|
76
|
+
return this.encryptCBC(data, Datakey, Dataiv);
|
|
77
|
+
}
|
|
78
|
+
} catch (error) {
|
|
79
|
+
throw new InternalServerErrorException('Encryption process failed');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static decryptRequest(data: any, Datakey: any, Dataiv: any, type?: any) {
|
|
84
|
+
try {
|
|
85
|
+
switch (type) {
|
|
86
|
+
case 'GCM':
|
|
87
|
+
return this.decryptGCM(data, Datakey, Dataiv);
|
|
88
|
+
case 'CBC':
|
|
89
|
+
return this.decryptCBC(data, Datakey, Dataiv);
|
|
90
|
+
default:
|
|
91
|
+
return this.decryptCBC(data, Datakey, Dataiv);
|
|
92
|
+
}
|
|
93
|
+
} catch (error) {
|
|
94
|
+
throw new InternalServerErrorException('Encryption process failed');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import * as xlsx from 'xlsx';
|
|
2
|
-
|
|
3
|
-
export class ExcelUtil {
|
|
4
|
-
static readExcel(fileBuffer: Buffer): Record<string, any[]> {
|
|
5
|
-
const workbook = xlsx.read(fileBuffer, { type: 'buffer' });
|
|
6
|
-
const data: Record<string, any[]> = {};
|
|
7
|
-
|
|
8
|
-
workbook.SheetNames.forEach((sheetName) => {
|
|
9
|
-
const sheet = workbook.Sheets[sheetName];
|
|
10
|
-
data[sheetName] = xlsx.utils.sheet_to_json(sheet);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
return data;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
import * as xlsx from 'xlsx';
|
|
2
|
+
|
|
3
|
+
export class ExcelUtil {
|
|
4
|
+
static readExcel(fileBuffer: Buffer): Record<string, any[]> {
|
|
5
|
+
const workbook = xlsx.read(fileBuffer, { type: 'buffer' });
|
|
6
|
+
const data: Record<string, any[]> = {};
|
|
7
|
+
|
|
8
|
+
workbook.SheetNames.forEach((sheetName) => {
|
|
9
|
+
const sheet = workbook.Sheets[sheetName];
|
|
10
|
+
data[sheetName] = xlsx.utils.sheet_to_json(sheet);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { ModuleRef } from '@nestjs/core';
|
|
3
|
-
import { DataSource, Repository } from 'typeorm';
|
|
4
|
-
import { getRepositoryToken } from '@nestjs/typeorm';
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class ReflectionHelper {
|
|
8
|
-
constructor(
|
|
9
|
-
private moduleRef: ModuleRef,
|
|
10
|
-
private dataSource: DataSource,
|
|
11
|
-
) {}
|
|
12
|
-
|
|
13
|
-
getRepoService(entityName: string): Repository<any> | null {
|
|
14
|
-
const entityMetadata: any = this.dataSource.entityMetadatas.find(
|
|
15
|
-
(meta) =>
|
|
16
|
-
meta.name === entityName ||
|
|
17
|
-
(meta.target && (meta.target as any).name === entityName),
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
if (!entityMetadata) {
|
|
21
|
-
console.error(`Entity "${entityName}" not found in TypeORM metadata`);
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
return this.moduleRef.get<Repository<any>>(
|
|
27
|
-
getRepositoryToken(entityMetadata.target),
|
|
28
|
-
{ strict: false },
|
|
29
|
-
);
|
|
30
|
-
} catch (error) {
|
|
31
|
-
console.error(`Repository for "${entityName}" not found:`, error.message);
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async getBean<T>(beanName: string): Promise<T | null> {
|
|
37
|
-
try {
|
|
38
|
-
const provider = this.moduleRef.get<T>(beanName as any, {
|
|
39
|
-
strict: false,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
if (!provider) {
|
|
43
|
-
console.error(`Bean "${beanName}" not found in moduleRef.`);
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return provider;
|
|
48
|
-
} catch (error) {
|
|
49
|
-
console.error(`Bean "${beanName}" not found:`, error.message);
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { ModuleRef } from '@nestjs/core';
|
|
3
|
+
import { DataSource, Repository } from 'typeorm';
|
|
4
|
+
import { getRepositoryToken } from '@nestjs/typeorm';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class ReflectionHelper {
|
|
8
|
+
constructor(
|
|
9
|
+
private moduleRef: ModuleRef,
|
|
10
|
+
private dataSource: DataSource,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
getRepoService(entityName: string): Repository<any> | null {
|
|
14
|
+
const entityMetadata: any = this.dataSource.entityMetadatas.find(
|
|
15
|
+
(meta) =>
|
|
16
|
+
meta.name === entityName ||
|
|
17
|
+
(meta.target && (meta.target as any).name === entityName),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
if (!entityMetadata) {
|
|
21
|
+
console.error(`Entity "${entityName}" not found in TypeORM metadata`);
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
return this.moduleRef.get<Repository<any>>(
|
|
27
|
+
getRepositoryToken(entityMetadata.target),
|
|
28
|
+
{ strict: false },
|
|
29
|
+
);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error(`Repository for "${entityName}" not found:`, error.message);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async getBean<T>(beanName: string): Promise<T | null> {
|
|
37
|
+
try {
|
|
38
|
+
const provider = this.moduleRef.get<T>(beanName as any, {
|
|
39
|
+
strict: false,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (!provider) {
|
|
43
|
+
console.error(`Bean "${beanName}" not found in moduleRef.`);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return provider;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error(`Bean "${beanName}" not found:`, error.message);
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { UserService } from '../service/user.service';
|
|
2
|
-
import { RoleService } from '../service/role.service';
|
|
3
|
-
export declare class RoleController {
|
|
4
|
-
private readonly userService;
|
|
5
|
-
private readonly roleService;
|
|
6
|
-
constructor(userService: UserService, roleService: RoleService);
|
|
7
|
-
createRole(body: {
|
|
8
|
-
name: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
status?: 'ACTIVE' | 'INACTIVE';
|
|
11
|
-
copyFromRoleId?: number;
|
|
12
|
-
}, request: Request & {
|
|
13
|
-
user: any;
|
|
14
|
-
}): Promise<{
|
|
15
|
-
success: boolean;
|
|
16
|
-
msg: string;
|
|
17
|
-
role: {
|
|
18
|
-
id: number;
|
|
19
|
-
name: string;
|
|
20
|
-
status: string;
|
|
21
|
-
code: string;
|
|
22
|
-
};
|
|
23
|
-
}>;
|
|
24
|
-
updateRole(id: number, body: {
|
|
25
|
-
name?: string;
|
|
26
|
-
description?: string;
|
|
27
|
-
status?: 'ACTIVE' | 'INACTIVE';
|
|
28
|
-
copyFromRoleId?: number;
|
|
29
|
-
}, req: Request & {
|
|
30
|
-
user: any;
|
|
31
|
-
}): Promise<{
|
|
32
|
-
success: boolean;
|
|
33
|
-
msg: string;
|
|
34
|
-
role: {
|
|
35
|
-
id: number;
|
|
36
|
-
name: string;
|
|
37
|
-
status: string;
|
|
38
|
-
code: string;
|
|
39
|
-
};
|
|
40
|
-
}>;
|
|
41
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.RoleController = void 0;
|
|
16
|
-
const common_1 = require("@nestjs/common");
|
|
17
|
-
const user_service_1 = require("../service/user.service");
|
|
18
|
-
const global_constant_1 = require("../../../constant/global.constant");
|
|
19
|
-
const role_service_1 = require("../service/role.service");
|
|
20
|
-
const jwt_guard_1 = require("../../auth/guards/jwt.guard");
|
|
21
|
-
let RoleController = class RoleController {
|
|
22
|
-
constructor(userService, roleService) {
|
|
23
|
-
this.userService = userService;
|
|
24
|
-
this.roleService = roleService;
|
|
25
|
-
}
|
|
26
|
-
async createRole(body, request) {
|
|
27
|
-
let requestedUser = request.user;
|
|
28
|
-
let loggedInUser = await this.userService.getEntityData(global_constant_1.ENTITYTYPE_USER, requestedUser.id);
|
|
29
|
-
return this.roleService.createRole(body, loggedInUser);
|
|
30
|
-
}
|
|
31
|
-
async updateRole(id, body, req) {
|
|
32
|
-
let requestedUser = req.user;
|
|
33
|
-
let loggedInUser = await this.userService.getEntityData(global_constant_1.ENTITYTYPE_USER, requestedUser.id);
|
|
34
|
-
return this.roleService.updateRole(id, body, loggedInUser);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
exports.RoleController = RoleController;
|
|
38
|
-
__decorate([
|
|
39
|
-
(0, common_1.Post)('create'),
|
|
40
|
-
__param(0, (0, common_1.Body)()),
|
|
41
|
-
__param(1, (0, common_1.Req)()),
|
|
42
|
-
__metadata("design:type", Function),
|
|
43
|
-
__metadata("design:paramtypes", [Object, Object]),
|
|
44
|
-
__metadata("design:returntype", Promise)
|
|
45
|
-
], RoleController.prototype, "createRole", null);
|
|
46
|
-
__decorate([
|
|
47
|
-
(0, common_1.Post)('update/:id'),
|
|
48
|
-
__param(0, (0, common_1.Param)('id')),
|
|
49
|
-
__param(1, (0, common_1.Body)()),
|
|
50
|
-
__param(2, (0, common_1.Req)()),
|
|
51
|
-
__metadata("design:type", Function),
|
|
52
|
-
__metadata("design:paramtypes", [Number, Object, Object]),
|
|
53
|
-
__metadata("design:returntype", Promise)
|
|
54
|
-
], RoleController.prototype, "updateRole", null);
|
|
55
|
-
exports.RoleController = RoleController = __decorate([
|
|
56
|
-
(0, common_1.Controller)('role'),
|
|
57
|
-
(0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
|
|
58
|
-
__param(0, (0, common_1.Inject)('UserService')),
|
|
59
|
-
__param(1, (0, common_1.Inject)('RoleService')),
|
|
60
|
-
__metadata("design:paramtypes", [user_service_1.UserService,
|
|
61
|
-
role_service_1.RoleService])
|
|
62
|
-
], RoleController);
|
|
63
|
-
//# sourceMappingURL=role.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"role.controller.js","sourceRoot":"","sources":["../../../../src/module/user/controller/role.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAuF;AACvF,0DAAsD;AACtD,uEAA+D;AAC/D,0DAAsD;AAItD,2DAAgE;AAGzD,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAC0C,WAAwB,EACxB,WAAwB;QADxB,gBAAW,GAAX,WAAW,CAAa;QACxB,gBAAW,GAAX,WAAW,CAAa;IAC/D,CAAC;IAGE,AAAN,KAAK,CAAC,UAAU,CAEd,IAKC,EACM,OAAgC;QAEvC,IAAI,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;QACjC,IAAI,YAAY,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,aAAa,CACrD,iCAAe,EACf,aAAa,CAAC,EAAE,CACjB,CAAC;QACF,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,EAAE,YAAwB,CAAC,CAAC;IACrE,CAAC;IAGK,AAAN,KAAK,CAAC,UAAU,CACD,EAAU,EAEvB,IAKC,EACM,GAA4B;QAEnC,IAAI,aAAa,GAAG,GAAG,CAAC,IAAI,CAAC;QAC7B,IAAI,YAAY,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,aAAa,CACrD,iCAAe,EACf,aAAa,CAAC,EAAE,CACjB,CAAC;QACF,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,EAAE,YAAwB,CAAC,CAAC;IACzE,CAAC;CACF,CAAA;AA5CY,wCAAc;AAOnB;IADL,IAAA,aAAI,EAAC,QAAQ,CAAC;IAEZ,WAAA,IAAA,aAAI,GAAE,CAAA;IAON,WAAA,IAAA,YAAG,GAAE,CAAA;;;;gDAQP;AAGK;IADL,IAAA,aAAI,EAAC,YAAY,CAAC;IAEhB,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IACX,WAAA,IAAA,aAAI,GAAE,CAAA;IAON,WAAA,IAAA,YAAG,GAAE,CAAA;;;;gDAQP;yBA3CU,cAAc;IAF1B,IAAA,mBAAU,EAAC,MAAM,CAAC;IAClB,IAAA,kBAAS,EAAC,wBAAY,CAAC;IAGnB,WAAA,IAAA,eAAM,EAAC,aAAa,CAAC,CAAA;IACrB,WAAA,IAAA,eAAM,EAAC,aAAa,CAAC,CAAA;qCAD+B,0BAAW;QACX,0BAAW;GAHvD,cAAc,CA4C1B"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Body, Controller, Inject, Param, Post, Req, UseGuards } from '@nestjs/common';
|
|
2
|
-
import { UserService } from '../service/user.service';
|
|
3
|
-
import { ENTITYTYPE_USER } from 'src/constant/global.constant';
|
|
4
|
-
import { RoleService } from '../service/role.service';
|
|
5
|
-
import { UserData } from '../entity/user.entity';
|
|
6
|
-
import { request } from 'express';
|
|
7
|
-
import { AuthGuard } from '@nestjs/passport';
|
|
8
|
-
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
9
|
-
@Controller('role')
|
|
10
|
-
@UseGuards(JwtAuthGuard)
|
|
11
|
-
export class RoleController {
|
|
12
|
-
constructor(
|
|
13
|
-
@Inject('UserService') private readonly userService: UserService,
|
|
14
|
-
@Inject('RoleService') private readonly roleService: RoleService,
|
|
15
|
-
) {}
|
|
16
|
-
|
|
17
|
-
@Post('create')
|
|
18
|
-
async createRole(
|
|
19
|
-
@Body()
|
|
20
|
-
body: {
|
|
21
|
-
name: string;
|
|
22
|
-
description?: string;
|
|
23
|
-
status?: 'ACTIVE' | 'INACTIVE';
|
|
24
|
-
copyFromRoleId?: number;
|
|
25
|
-
},
|
|
26
|
-
@Req() request: Request & { user: any },
|
|
27
|
-
) {
|
|
28
|
-
let requestedUser = request.user;
|
|
29
|
-
let loggedInUser = await this.userService.getEntityData(
|
|
30
|
-
ENTITYTYPE_USER,
|
|
31
|
-
requestedUser.id,
|
|
32
|
-
);
|
|
33
|
-
return this.roleService.createRole(body, loggedInUser as UserData);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@Post('update/:id')
|
|
37
|
-
async updateRole(
|
|
38
|
-
@Param('id') id: number,
|
|
39
|
-
@Body()
|
|
40
|
-
body: {
|
|
41
|
-
name?: string;
|
|
42
|
-
description?: string;
|
|
43
|
-
status?: 'ACTIVE' | 'INACTIVE';
|
|
44
|
-
copyFromRoleId?: number; // <-- ADD THIS
|
|
45
|
-
},
|
|
46
|
-
@Req() req: Request & { user: any },
|
|
47
|
-
) {
|
|
48
|
-
let requestedUser = req.user;
|
|
49
|
-
let loggedInUser = await this.userService.getEntityData(
|
|
50
|
-
ENTITYTYPE_USER,
|
|
51
|
-
requestedUser.id,
|
|
52
|
-
);
|
|
53
|
-
return this.roleService.updateRole(id, body, loggedInUser as UserData);
|
|
54
|
-
}
|
|
55
|
-
}
|