@hed-hog/core 0.0.74 → 0.0.76
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/role/dto/create.dto.d.ts +5 -2
- package/dist/role/dto/create.dto.d.ts.map +1 -1
- package/dist/role/dto/create.dto.js +10 -1
- package/dist/role/dto/create.dto.js.map +1 -1
- package/dist/role/role.controller.d.ts +74 -8
- package/dist/role/role.controller.d.ts.map +1 -1
- package/dist/role/role.controller.js +13 -14
- package/dist/role/role.controller.js.map +1 -1
- package/dist/role/role.service.d.ts +74 -11
- package/dist/role/role.service.d.ts.map +1 -1
- package/dist/role/role.service.js +185 -44
- package/dist/role/role.service.js.map +1 -1
- package/hedhog/data/menu.yaml +12 -2
- package/package.json +3 -3
- package/src/role/dto/create.dto.ts +12 -3
- package/src/role/role.controller.ts +11 -10
- package/src/role/role.service.ts +222 -60
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export declare class CreateDTO extends WithLocaleDTO {
|
|
1
|
+
export declare class CreateDTO {
|
|
3
2
|
slug: string;
|
|
3
|
+
locale: Record<string, {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
}>;
|
|
4
7
|
}
|
|
5
8
|
//# sourceMappingURL=create.dto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.dto.d.ts","sourceRoot":"","sources":["../../../src/role/dto/create.dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.dto.d.ts","sourceRoot":"","sources":["../../../src/role/dto/create.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,SAAS;IAEpB,IAAI,EAAE,MAAM,CAAC;IASb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC/D"}
|
|
@@ -12,11 +12,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.CreateDTO = void 0;
|
|
13
13
|
const api_locale_1 = require("@hed-hog/api-locale");
|
|
14
14
|
const class_validator_1 = require("class-validator");
|
|
15
|
-
class CreateDTO
|
|
15
|
+
class CreateDTO {
|
|
16
16
|
}
|
|
17
17
|
exports.CreateDTO = CreateDTO;
|
|
18
18
|
__decorate([
|
|
19
19
|
(0, class_validator_1.IsString)({ message: (args) => (0, api_locale_1.getLocaleText)('validation.slugMustBeString', args.value) }),
|
|
20
20
|
__metadata("design:type", String)
|
|
21
21
|
], CreateDTO.prototype, "slug", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, class_validator_1.IsObject)({
|
|
24
|
+
message: (args) => (0, api_locale_1.getLocaleText)('validation.localeMustBeObject', args.value),
|
|
25
|
+
}),
|
|
26
|
+
(0, class_validator_1.IsNotEmpty)({
|
|
27
|
+
message: (args) => (0, api_locale_1.getLocaleText)('validation.localeRequired', args.value),
|
|
28
|
+
}),
|
|
29
|
+
__metadata("design:type", Object)
|
|
30
|
+
], CreateDTO.prototype, "locale", void 0);
|
|
22
31
|
//# sourceMappingURL=create.dto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.dto.js","sourceRoot":"","sources":["../../../src/role/dto/create.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"create.dto.js","sourceRoot":"","sources":["../../../src/role/dto/create.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAoD;AACpD,qDAAiE;AAEjE,MAAa,SAAS;CAYrB;AAZD,8BAYC;AAVC;IADC,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,0BAAa,EAAC,6BAA6B,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;;uCAC7E;AASb;IAPC,IAAA,0BAAQ,EAAC;QACR,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAChB,IAAA,0BAAa,EAAC,+BAA+B,EAAE,IAAI,CAAC,KAAK,CAAC;KAC7D,CAAC;IACD,IAAA,4BAAU,EAAC;QACV,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,0BAAa,EAAC,2BAA2B,EAAE,IAAI,CAAC,KAAK,CAAC;KAC1E,CAAC;;yCAC4D"}
|
|
@@ -7,13 +7,13 @@ export declare class RoleController {
|
|
|
7
7
|
private readonly roleService;
|
|
8
8
|
constructor(roleService: RoleService);
|
|
9
9
|
list(paginationParams: any, locale: any): Promise<{
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
data: any[];
|
|
11
|
+
total: number;
|
|
12
12
|
page: number;
|
|
13
|
-
pageSize:
|
|
13
|
+
pageSize: any;
|
|
14
14
|
prev: number;
|
|
15
15
|
next: number;
|
|
16
|
-
|
|
16
|
+
lastPage: number;
|
|
17
17
|
}>;
|
|
18
18
|
listUsers(paginationParams: any, roleId: number): Promise<{
|
|
19
19
|
total: any;
|
|
@@ -33,7 +33,7 @@ export declare class RoleController {
|
|
|
33
33
|
next: number;
|
|
34
34
|
data: any;
|
|
35
35
|
}>;
|
|
36
|
-
listRoutes(paginationParams: any, roleId: number): Promise<{
|
|
36
|
+
listRoutes(paginationParams: any, roleId: number, search?: string, searchType?: 'contains' | 'startsWith' | 'endsWith', method?: string): Promise<{
|
|
37
37
|
total: any;
|
|
38
38
|
lastPage: number;
|
|
39
39
|
page: number;
|
|
@@ -63,9 +63,75 @@ export declare class RoleController {
|
|
|
63
63
|
updateScreens(roleId: number, data: UpdateIdsDTO): Promise<{
|
|
64
64
|
count: number;
|
|
65
65
|
}>;
|
|
66
|
-
show(roleId: number
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
show(roleId: number): Promise<{
|
|
67
|
+
locale: Record<string, {
|
|
68
|
+
name: string;
|
|
69
|
+
description: string;
|
|
70
|
+
}>;
|
|
71
|
+
role_locale: ({
|
|
72
|
+
locale: {
|
|
73
|
+
code: string;
|
|
74
|
+
};
|
|
75
|
+
} & {
|
|
76
|
+
name: string;
|
|
77
|
+
id: number;
|
|
78
|
+
description: string | null;
|
|
79
|
+
created_at: Date;
|
|
80
|
+
updated_at: Date;
|
|
81
|
+
locale_id: number;
|
|
82
|
+
role_id: number;
|
|
83
|
+
})[];
|
|
84
|
+
id: number;
|
|
85
|
+
created_at: Date;
|
|
86
|
+
updated_at: Date;
|
|
87
|
+
slug: string;
|
|
88
|
+
}>;
|
|
89
|
+
create(data: CreateDTO): Promise<{
|
|
90
|
+
locale: Record<string, {
|
|
91
|
+
name: string;
|
|
92
|
+
description: string;
|
|
93
|
+
}>;
|
|
94
|
+
role_locale: ({
|
|
95
|
+
locale: {
|
|
96
|
+
code: string;
|
|
97
|
+
};
|
|
98
|
+
} & {
|
|
99
|
+
name: string;
|
|
100
|
+
id: number;
|
|
101
|
+
description: string | null;
|
|
102
|
+
created_at: Date;
|
|
103
|
+
updated_at: Date;
|
|
104
|
+
locale_id: number;
|
|
105
|
+
role_id: number;
|
|
106
|
+
})[];
|
|
107
|
+
id: number;
|
|
108
|
+
created_at: Date;
|
|
109
|
+
updated_at: Date;
|
|
110
|
+
slug: string;
|
|
111
|
+
}>;
|
|
112
|
+
update(roleId: number, data: UpdateDTO): Promise<{
|
|
113
|
+
locale: Record<string, {
|
|
114
|
+
name: string;
|
|
115
|
+
description: string;
|
|
116
|
+
}>;
|
|
117
|
+
role_locale: ({
|
|
118
|
+
locale: {
|
|
119
|
+
code: string;
|
|
120
|
+
};
|
|
121
|
+
} & {
|
|
122
|
+
name: string;
|
|
123
|
+
id: number;
|
|
124
|
+
description: string | null;
|
|
125
|
+
created_at: Date;
|
|
126
|
+
updated_at: Date;
|
|
127
|
+
locale_id: number;
|
|
128
|
+
role_id: number;
|
|
129
|
+
})[];
|
|
130
|
+
id: number;
|
|
131
|
+
created_at: Date;
|
|
132
|
+
updated_at: Date;
|
|
133
|
+
slug: string;
|
|
134
|
+
}>;
|
|
69
135
|
delete(data: DeleteDTO): Promise<{
|
|
70
136
|
count: number;
|
|
71
137
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.controller.d.ts","sourceRoot":"","sources":["../../src/role/role.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"role.controller.d.ts","sourceRoot":"","sources":["../../src/role/role.controller.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAEa,cAAc;IAGvB,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,WAAW;IAIrC,IAAI,CAAe,gBAAgB,KAAA,EAAY,MAAM,KAAA;;;;;;;;;IAKrD,SAAS,CACC,gBAAgB,KAAA,EACC,MAAM,EAAE,MAAM;;;;;;;;;IAMzC,SAAS,CACC,gBAAgB,KAAA,EACC,MAAM,EAAE,MAAM,EACnC,MAAM,KAAA;;;;;;;;;IAMZ,UAAU,CACA,gBAAgB,KAAA,EACC,MAAM,EAAE,MAAM,EAC5B,MAAM,CAAC,EAAE,MAAM,EACX,UAAU,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,UAAU,EACvD,MAAM,CAAC,EAAE,MAAM;;;;;;;;;IAM5B,WAAW,CACD,gBAAgB,KAAA,EACC,MAAM,EAAE,MAAM,EACnC,MAAM,KAAA;;;;;;;;;IAMZ,WAAW,CACgB,MAAM,EAAE,MAAM,EACrC,IAAI,EAAE,YAAY;;;IAMtB,WAAW,CACgB,MAAM,EAAE,MAAM,EACrC,IAAI,EAAE,YAAY;;;IAMtB,YAAY,CACe,MAAM,EAAE,MAAM,EACrC,IAAI,EAAE,YAAY;;;IAMtB,aAAa,CACc,MAAM,EAAE,MAAM,EACrC,IAAI,EAAE,YAAY;;;IAMtB,IAAI,CAAgC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;IAKlD,MAAM,CAAS,IAAI,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;;;IAK9B,MAAM,CACqB,MAAM,EAAE,MAAM,EACrC,IAAI,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;;;IAMnB,MAAM,CAAS,IAAI,EAAE,SAAS;;;CAGrC"}
|
|
@@ -13,12 +13,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.RoleController = void 0;
|
|
16
|
+
const api_1 = require("@hed-hog/api");
|
|
17
|
+
const api_locale_1 = require("@hed-hog/api-locale");
|
|
16
18
|
const api_pagination_1 = require("@hed-hog/api-pagination");
|
|
17
19
|
const common_1 = require("@nestjs/common");
|
|
18
20
|
const delete_dto_1 = require("../dto/delete.dto");
|
|
19
21
|
const update_ids_dto_1 = require("../dto/update-ids.dto");
|
|
20
|
-
const api_locale_1 = require("@hed-hog/api-locale");
|
|
21
|
-
const api_1 = require("@hed-hog/api");
|
|
22
22
|
const create_dto_1 = require("./dto/create.dto");
|
|
23
23
|
const update_dto_1 = require("./dto/update.dto");
|
|
24
24
|
const role_service_1 = require("./role.service");
|
|
@@ -27,7 +27,7 @@ let RoleController = class RoleController {
|
|
|
27
27
|
this.roleService = roleService;
|
|
28
28
|
}
|
|
29
29
|
async list(paginationParams, locale) {
|
|
30
|
-
return this.roleService.list(
|
|
30
|
+
return this.roleService.list(paginationParams, locale);
|
|
31
31
|
}
|
|
32
32
|
async listUsers(paginationParams, roleId) {
|
|
33
33
|
return this.roleService.listUsers(roleId, paginationParams);
|
|
@@ -35,8 +35,8 @@ let RoleController = class RoleController {
|
|
|
35
35
|
async listMenus(paginationParams, roleId, locale) {
|
|
36
36
|
return this.roleService.listMenus(locale, roleId, paginationParams);
|
|
37
37
|
}
|
|
38
|
-
async listRoutes(paginationParams, roleId) {
|
|
39
|
-
return this.roleService.listRoutes(roleId, paginationParams);
|
|
38
|
+
async listRoutes(paginationParams, roleId, search, searchType, method) {
|
|
39
|
+
return this.roleService.listRoutes(roleId, paginationParams, search, searchType, method);
|
|
40
40
|
}
|
|
41
41
|
async listScreens(paginationParams, roleId, locale) {
|
|
42
42
|
return this.roleService.listScreens(locale, roleId, paginationParams);
|
|
@@ -53,17 +53,14 @@ let RoleController = class RoleController {
|
|
|
53
53
|
async updateScreens(roleId, data) {
|
|
54
54
|
return this.roleService.updateScreens(roleId, data);
|
|
55
55
|
}
|
|
56
|
-
async show(roleId
|
|
57
|
-
return this.roleService.get(
|
|
56
|
+
async show(roleId) {
|
|
57
|
+
return this.roleService.get(roleId);
|
|
58
58
|
}
|
|
59
59
|
async create(data) {
|
|
60
60
|
return this.roleService.create(data);
|
|
61
61
|
}
|
|
62
62
|
async update(roleId, data) {
|
|
63
|
-
return this.roleService.update(
|
|
64
|
-
id: roleId,
|
|
65
|
-
data,
|
|
66
|
-
});
|
|
63
|
+
return this.roleService.update(roleId, data);
|
|
67
64
|
}
|
|
68
65
|
async delete(data) {
|
|
69
66
|
return this.roleService.delete(data);
|
|
@@ -99,8 +96,11 @@ __decorate([
|
|
|
99
96
|
(0, common_1.Get)(':roleId/route'),
|
|
100
97
|
__param(0, (0, api_pagination_1.Pagination)()),
|
|
101
98
|
__param(1, (0, common_1.Param)('roleId', common_1.ParseIntPipe)),
|
|
99
|
+
__param(2, (0, common_1.Query)('search')),
|
|
100
|
+
__param(3, (0, common_1.Query)('searchType')),
|
|
101
|
+
__param(4, (0, common_1.Query)('method')),
|
|
102
102
|
__metadata("design:type", Function),
|
|
103
|
-
__metadata("design:paramtypes", [Object, Number]),
|
|
103
|
+
__metadata("design:paramtypes", [Object, Number, String, String, String]),
|
|
104
104
|
__metadata("design:returntype", Promise)
|
|
105
105
|
], RoleController.prototype, "listRoutes", null);
|
|
106
106
|
__decorate([
|
|
@@ -147,9 +147,8 @@ __decorate([
|
|
|
147
147
|
__decorate([
|
|
148
148
|
(0, common_1.Get)(':roleId'),
|
|
149
149
|
__param(0, (0, common_1.Param)('roleId', common_1.ParseIntPipe)),
|
|
150
|
-
__param(1, (0, api_locale_1.Locale)()),
|
|
151
150
|
__metadata("design:type", Function),
|
|
152
|
-
__metadata("design:paramtypes", [Number
|
|
151
|
+
__metadata("design:paramtypes", [Number]),
|
|
153
152
|
__metadata("design:returntype", Promise)
|
|
154
153
|
], RoleController.prototype, "show", null);
|
|
155
154
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.controller.js","sourceRoot":"","sources":["../../src/role/role.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4DAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"role.controller.js","sourceRoot":"","sources":["../../src/role/role.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAAoC;AACpC,oDAA6C;AAC7C,4DAAqD;AACrD,2CAYwB;AACxB,kDAA8C;AAC9C,0DAAqD;AACrD,iDAA6C;AAC7C,iDAA6C;AAC7C,iDAA6C;AAItC,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAEmB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IACxC,CAAC;IAGE,AAAN,KAAK,CAAC,IAAI,CAAe,gBAAgB,EAAY,MAAM;QACzD,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;IAGK,AAAN,KAAK,CAAC,SAAS,CACC,gBAAgB,EACC,MAAc;QAE7C,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC9D,CAAC;IAGK,AAAN,KAAK,CAAC,SAAS,CACC,g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AAE,CAAA;;qCAAO,sBAAS;;4CAEnC;yBArGU,cAAc;IAF1B,IAAA,UAAI,GAAE;IACN,IAAA,mBAAU,EAAC,MAAM,CAAC;IAGd,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAW,CAAC,CAAC,CAAA;qCACR,0BAAW;GAHhC,cAAc,CAsG1B"}
|
|
@@ -40,7 +40,7 @@ export declare class RoleService {
|
|
|
40
40
|
next: number;
|
|
41
41
|
data: any;
|
|
42
42
|
}>;
|
|
43
|
-
listRoutes(roleId: number, paginationParams: PaginationDTO): Promise<{
|
|
43
|
+
listRoutes(roleId: number, paginationParams: PaginationDTO, search?: string, searchType?: 'contains' | 'startsWith' | 'endsWith', method?: string): Promise<{
|
|
44
44
|
total: any;
|
|
45
45
|
lastPage: number;
|
|
46
46
|
page: number;
|
|
@@ -58,21 +58,84 @@ export declare class RoleService {
|
|
|
58
58
|
next: number;
|
|
59
59
|
data: any;
|
|
60
60
|
}>;
|
|
61
|
-
list(
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
list(paginationParams: any, locale: string): Promise<{
|
|
62
|
+
data: any[];
|
|
63
|
+
total: number;
|
|
64
64
|
page: number;
|
|
65
|
-
pageSize:
|
|
65
|
+
pageSize: any;
|
|
66
66
|
prev: number;
|
|
67
67
|
next: number;
|
|
68
|
-
|
|
68
|
+
lastPage: number;
|
|
69
69
|
}>;
|
|
70
|
-
get(
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
get(roleId: number): Promise<{
|
|
71
|
+
locale: Record<string, {
|
|
72
|
+
name: string;
|
|
73
|
+
description: string;
|
|
74
|
+
}>;
|
|
75
|
+
role_locale: ({
|
|
76
|
+
locale: {
|
|
77
|
+
code: string;
|
|
78
|
+
};
|
|
79
|
+
} & {
|
|
80
|
+
name: string;
|
|
81
|
+
id: number;
|
|
82
|
+
description: string | null;
|
|
83
|
+
created_at: Date;
|
|
84
|
+
updated_at: Date;
|
|
85
|
+
locale_id: number;
|
|
86
|
+
role_id: number;
|
|
87
|
+
})[];
|
|
73
88
|
id: number;
|
|
74
|
-
|
|
75
|
-
|
|
89
|
+
created_at: Date;
|
|
90
|
+
updated_at: Date;
|
|
91
|
+
slug: string;
|
|
92
|
+
}>;
|
|
93
|
+
create(body: CreateDTO): Promise<{
|
|
94
|
+
locale: Record<string, {
|
|
95
|
+
name: string;
|
|
96
|
+
description: string;
|
|
97
|
+
}>;
|
|
98
|
+
role_locale: ({
|
|
99
|
+
locale: {
|
|
100
|
+
code: string;
|
|
101
|
+
};
|
|
102
|
+
} & {
|
|
103
|
+
name: string;
|
|
104
|
+
id: number;
|
|
105
|
+
description: string | null;
|
|
106
|
+
created_at: Date;
|
|
107
|
+
updated_at: Date;
|
|
108
|
+
locale_id: number;
|
|
109
|
+
role_id: number;
|
|
110
|
+
})[];
|
|
111
|
+
id: number;
|
|
112
|
+
created_at: Date;
|
|
113
|
+
updated_at: Date;
|
|
114
|
+
slug: string;
|
|
115
|
+
}>;
|
|
116
|
+
update(id: number, body: UpdateDTO): Promise<{
|
|
117
|
+
locale: Record<string, {
|
|
118
|
+
name: string;
|
|
119
|
+
description: string;
|
|
120
|
+
}>;
|
|
121
|
+
role_locale: ({
|
|
122
|
+
locale: {
|
|
123
|
+
code: string;
|
|
124
|
+
};
|
|
125
|
+
} & {
|
|
126
|
+
name: string;
|
|
127
|
+
id: number;
|
|
128
|
+
description: string | null;
|
|
129
|
+
created_at: Date;
|
|
130
|
+
updated_at: Date;
|
|
131
|
+
locale_id: number;
|
|
132
|
+
role_id: number;
|
|
133
|
+
})[];
|
|
134
|
+
id: number;
|
|
135
|
+
created_at: Date;
|
|
136
|
+
updated_at: Date;
|
|
137
|
+
slug: string;
|
|
138
|
+
}>;
|
|
76
139
|
delete({ ids }: DeleteDTO, locale?: string): Promise<{
|
|
77
140
|
count: number;
|
|
78
141
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.service.d.ts","sourceRoot":"","sources":["../../src/role/role.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"role.service.d.ts","sourceRoot":"","sources":["../../src/role/role.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAiB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAOpD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBACa,WAAW;IAGpB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAElC,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAJb,aAAa,EAAE,aAAa,EAE5B,iBAAiB,EAAE,iBAAiB,EAEpC,aAAa,EAAE,aAAa;IAGzC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,YAAY,GAAE,OAAO,CAAC;QAAC,KAAK,EAAC,MAAM,CAAA;KAAC,CAAC;IAgB1E,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAE,OAAO,CAAC;QAAC,KAAK,EAAC,MAAM,CAAA;KAAC,CAAC;IAgBzE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAE,OAAO,CAAC;QAAC,KAAK,EAAC,MAAM,CAAA;KAAC,CAAC;IAgBxE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAE,OAAO,CAAC;QAAC,KAAK,EAAC,MAAM,CAAA;KAAC,CAAC;IAgBvE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa;;;;;;;;;IAoBzD,SAAS,CACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,aAAa;;;;;;;;;IAgC3B,UAAU,CACd,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,aAAa,EAC/B,MAAM,CAAC,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,UAAU,EACnD,MAAM,CAAC,EAAE,MAAM;;;;;;;;;IA+CX,WAAW,CACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,aAAa;;;;;;;;;IAgC1B,IAAI,CAAC,gBAAgB,KAAA,EAAE,MAAM,EAAE,MAAM;;;;;;;;;IAwGtC,GAAG,CAAC,MAAM,EAAE,MAAM;;kBAyBU,MAAM;yBAAe,MAAM;;;;;;;;;;;;;;;;;;;;IAQvD,MAAM,CAAC,IAAI,EAAE,SAAS;;kBARM,MAAM;yBAAe,MAAM;;;;;;;;;;;;;;;;;;;;IAmCvD,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS;;kBAnCN,MAAM;yBAAe,MAAM;;;;;;;;;;;;;;;;;;;;IA2EvD,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,MAAM,GAAE,MAAa,GAAE,OAAO,CAAC;QAAC,KAAK,EAAC,MAAM,CAAA;KAAC,CAAC;CAehF"}
|
|
@@ -13,7 +13,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.RoleService = void 0;
|
|
16
|
-
const api_1 = require("@hed-hog/api");
|
|
17
16
|
const api_locale_1 = require("@hed-hog/api-locale");
|
|
18
17
|
const api_pagination_1 = require("@hed-hog/api-pagination");
|
|
19
18
|
const api_prisma_1 = require("@hed-hog/api-prisma");
|
|
@@ -120,8 +119,33 @@ let RoleService = class RoleService {
|
|
|
120
119
|
},
|
|
121
120
|
}, 'menu_locale');
|
|
122
121
|
}
|
|
123
|
-
async listRoutes(roleId, paginationParams) {
|
|
122
|
+
async listRoutes(roleId, paginationParams, search, searchType, method) {
|
|
123
|
+
const whereClause = {};
|
|
124
|
+
// Filtro de busca por URL
|
|
125
|
+
if (search) {
|
|
126
|
+
if (searchType === 'startsWith') {
|
|
127
|
+
whereClause.url = {
|
|
128
|
+
startsWith: search,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
else if (searchType === 'endsWith') {
|
|
132
|
+
whereClause.url = {
|
|
133
|
+
endsWith: search,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// contains (padrão)
|
|
138
|
+
whereClause.url = {
|
|
139
|
+
contains: search,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Filtro por método HTTP
|
|
144
|
+
if (method && method !== 'all') {
|
|
145
|
+
whereClause.method = method;
|
|
146
|
+
}
|
|
124
147
|
return this.paginationService.paginate(this.prismaService.route, paginationParams, {
|
|
148
|
+
where: whereClause,
|
|
125
149
|
include: {
|
|
126
150
|
role_route: {
|
|
127
151
|
where: {
|
|
@@ -160,60 +184,177 @@ let RoleService = class RoleService {
|
|
|
160
184
|
},
|
|
161
185
|
}, 'screen_locale');
|
|
162
186
|
}
|
|
163
|
-
async list(
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
187
|
+
async list(paginationParams, locale) {
|
|
188
|
+
var _a;
|
|
189
|
+
const localeRecord = await this.localeService.getByCode(locale);
|
|
190
|
+
if (!localeRecord) {
|
|
191
|
+
throw new Error((0, api_locale_1.getLocaleText)('localeNotFound', locale, `Locale ${locale} not found`).replace('{{locale}}', locale));
|
|
192
|
+
}
|
|
193
|
+
const localeId = localeRecord.id;
|
|
194
|
+
const searchRaw = ((_a = paginationParams.search) !== null && _a !== void 0 ? _a : '').toString().trim();
|
|
195
|
+
const hasSearch = searchRaw.length > 0;
|
|
196
|
+
const like = `%${searchRaw.toLowerCase()}%`;
|
|
197
|
+
const rowsQuery = hasSearch
|
|
198
|
+
? this.prismaService.$queryRaw `
|
|
199
|
+
SELECT
|
|
200
|
+
f.id AS role_id,
|
|
201
|
+
f.slug,
|
|
202
|
+
fl.locale_id,
|
|
203
|
+
fl.name,
|
|
204
|
+
fl.description,
|
|
205
|
+
(
|
|
206
|
+
SELECT json_agg(json_build_object('code', l.code, 'name', l.name))
|
|
207
|
+
FROM role_locale fl2
|
|
208
|
+
JOIN locale l ON l.id = fl2.locale_id
|
|
209
|
+
WHERE fl2.role_id = f.id
|
|
210
|
+
AND l.enabled = true
|
|
211
|
+
AND fl2.name IS NOT NULL
|
|
212
|
+
AND fl2.name != ''
|
|
213
|
+
AND fl2.description IS NOT NULL
|
|
214
|
+
AND fl2.description != ''
|
|
215
|
+
) AS available_locales
|
|
216
|
+
FROM role AS f
|
|
217
|
+
JOIN role_locale AS fl
|
|
218
|
+
ON fl.role_id = f.id
|
|
219
|
+
WHERE fl.locale_id = ${localeId}
|
|
220
|
+
AND (
|
|
221
|
+
LOWER(fl.name) LIKE ${like}
|
|
222
|
+
OR LOWER(fl.description) LIKE ${like}
|
|
223
|
+
)
|
|
224
|
+
ORDER BY f.id DESC
|
|
225
|
+
LIMIT ${paginationParams.take}
|
|
226
|
+
OFFSET ${paginationParams.skip}
|
|
227
|
+
`
|
|
228
|
+
: this.prismaService.$queryRaw `
|
|
229
|
+
SELECT
|
|
230
|
+
f.id AS role_id,
|
|
231
|
+
f.slug,
|
|
232
|
+
fl.locale_id,
|
|
233
|
+
fl.name,
|
|
234
|
+
fl.description,
|
|
235
|
+
(
|
|
236
|
+
SELECT json_agg(json_build_object('code', l.code, 'name', l.name))
|
|
237
|
+
FROM role_locale fl2
|
|
238
|
+
JOIN locale l ON l.id = fl2.locale_id
|
|
239
|
+
WHERE fl2.role_id = f.id
|
|
240
|
+
AND l.enabled = true
|
|
241
|
+
AND fl2.name IS NOT NULL
|
|
242
|
+
AND fl2.name != ''
|
|
243
|
+
AND fl2.description IS NOT NULL
|
|
244
|
+
AND fl2.description != ''
|
|
245
|
+
) AS available_locales
|
|
246
|
+
FROM role AS f
|
|
247
|
+
JOIN role_locale AS fl
|
|
248
|
+
ON fl.role_id = f.id
|
|
249
|
+
WHERE fl.locale_id = ${localeId}
|
|
250
|
+
ORDER BY f.id DESC
|
|
251
|
+
LIMIT ${paginationParams.take}
|
|
252
|
+
OFFSET ${paginationParams.skip}
|
|
253
|
+
`;
|
|
254
|
+
const countQuery = this.prismaService.role.count({
|
|
255
|
+
where: Object.assign({ role_locale: { some: { locale_id: localeId } } }, (hasSearch && {
|
|
256
|
+
OR: [
|
|
257
|
+
{ role_locale: { some: { locale_id: localeId, name: { contains: searchRaw, mode: 'insensitive' } } } },
|
|
258
|
+
{ role_locale: { some: { locale_id: localeId, description: { contains: searchRaw, mode: 'insensitive' } } } },
|
|
259
|
+
],
|
|
260
|
+
})),
|
|
261
|
+
});
|
|
262
|
+
const [rows, total] = await Promise.all([rowsQuery, countQuery]);
|
|
263
|
+
const mappedRows = rows.map((row) => (Object.assign(Object.assign({}, row), { available_locales: row.available_locales || [] })));
|
|
264
|
+
const pageSize = paginationParams.take;
|
|
265
|
+
const page = Math.floor(paginationParams.skip / pageSize) + 1;
|
|
266
|
+
const lastPage = Math.max(1, Math.ceil(total / pageSize));
|
|
267
|
+
const prev = page > 1 ? page - 1 : null;
|
|
268
|
+
const next = page < lastPage ? page + 1 : null;
|
|
269
|
+
return {
|
|
270
|
+
data: mappedRows,
|
|
271
|
+
total,
|
|
272
|
+
page,
|
|
273
|
+
pageSize,
|
|
274
|
+
prev,
|
|
275
|
+
next,
|
|
276
|
+
lastPage,
|
|
277
|
+
};
|
|
184
278
|
}
|
|
185
|
-
async get(
|
|
186
|
-
|
|
279
|
+
async get(roleId) {
|
|
280
|
+
const role = await this.prismaService.role.findUnique({
|
|
187
281
|
where: { id: roleId },
|
|
188
282
|
include: {
|
|
189
283
|
role_locale: {
|
|
190
|
-
|
|
284
|
+
include: {
|
|
191
285
|
locale: {
|
|
192
|
-
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
select: {
|
|
196
|
-
name: true,
|
|
197
|
-
description: true,
|
|
198
|
-
locale: {
|
|
199
|
-
select: {
|
|
200
|
-
code: true,
|
|
201
|
-
},
|
|
286
|
+
select: { code: true },
|
|
202
287
|
},
|
|
203
288
|
},
|
|
204
289
|
},
|
|
205
290
|
},
|
|
206
|
-
}));
|
|
207
|
-
}
|
|
208
|
-
async create({ slug }) {
|
|
209
|
-
return this.localeService.createModelWithLocale('role', 'role_id', {
|
|
210
|
-
slug,
|
|
211
291
|
});
|
|
292
|
+
if (!role) {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
const localeData = role.role_locale.reduce((acc, item) => {
|
|
296
|
+
const localeCode = item.locale.code;
|
|
297
|
+
acc[localeCode] = {
|
|
298
|
+
name: item.name,
|
|
299
|
+
description: item.description,
|
|
300
|
+
};
|
|
301
|
+
return acc;
|
|
302
|
+
}, {});
|
|
303
|
+
return Object.assign(Object.assign({}, role), { locale: localeData });
|
|
212
304
|
}
|
|
213
|
-
async
|
|
214
|
-
|
|
215
|
-
|
|
305
|
+
async create(body) {
|
|
306
|
+
const { locale, slug } = body;
|
|
307
|
+
const role = await this.prismaService.role.create({
|
|
308
|
+
data: { slug },
|
|
216
309
|
});
|
|
310
|
+
if (locale) {
|
|
311
|
+
await Promise.all(Object.entries(locale).map(async ([localeCode, localeData]) => {
|
|
312
|
+
const localeRecord = await this.localeService.getByCode(localeCode);
|
|
313
|
+
await this.prismaService.role_locale.create({
|
|
314
|
+
data: {
|
|
315
|
+
role_id: role.id,
|
|
316
|
+
locale_id: localeRecord.id,
|
|
317
|
+
name: localeData.name,
|
|
318
|
+
description: localeData.description,
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
}));
|
|
322
|
+
}
|
|
323
|
+
return this.get(role.id);
|
|
324
|
+
}
|
|
325
|
+
async update(id, body) {
|
|
326
|
+
const { locale } = body;
|
|
327
|
+
if (locale) {
|
|
328
|
+
await Promise.all(Object.entries(locale).map(async ([localeCode, localeData]) => {
|
|
329
|
+
const localeRecord = await this.localeService.getByCode(localeCode);
|
|
330
|
+
const existing = await this.prismaService.role_locale.findFirst({
|
|
331
|
+
where: {
|
|
332
|
+
role_id: id,
|
|
333
|
+
locale_id: localeRecord.id,
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
if (existing) {
|
|
337
|
+
await this.prismaService.role_locale.update({
|
|
338
|
+
where: { id: existing.id },
|
|
339
|
+
data: {
|
|
340
|
+
name: localeData.name,
|
|
341
|
+
description: localeData.description,
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
await this.prismaService.role_locale.create({
|
|
347
|
+
data: {
|
|
348
|
+
role_id: id,
|
|
349
|
+
locale_id: localeRecord.id,
|
|
350
|
+
name: localeData.name,
|
|
351
|
+
description: localeData.description,
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}));
|
|
356
|
+
}
|
|
357
|
+
return this.get(id);
|
|
217
358
|
}
|
|
218
359
|
async delete({ ids }, locale = 'en') {
|
|
219
360
|
if (ids == undefined || ids == null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.service.js","sourceRoot":"","sources":["../../src/role/role.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"role.service.js","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GAAG,EAAa,EAAE,SAAiB,IAAI;QACpD,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YACpC,MAAM,IAAI,4BAAmB,CAC3B,IAAA,0BAAa,EAAC,qBAAqB,EAAE,MAAM,EAAE,oDAAoD,CAAC,CACnG,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC;YACxC,KAAK,EAAE;gBACL,EAAE,EAAE;oBACF,EAAE,EAAE,GAAG;iBACR;aACF;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAnbY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,kCAAiB,CAAC,CAAC,CAAA;IAE3C,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAC,CAAA;qCAHR,0BAAa;QAET,kCAAiB;QAErB,0BAAa;GAPpC,WAAW,CAmbvB"}
|
package/hedhog/data/menu.yaml
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
relations:
|
|
8
8
|
role:
|
|
9
9
|
- where:
|
|
10
|
-
slug: admin
|
|
10
|
+
slug: admin
|
|
11
11
|
- url: /users
|
|
12
12
|
icon: users
|
|
13
13
|
name:
|
|
@@ -17,7 +17,17 @@
|
|
|
17
17
|
relations:
|
|
18
18
|
role:
|
|
19
19
|
- where:
|
|
20
|
-
slug: admin
|
|
20
|
+
slug: admin
|
|
21
|
+
- url: /roles
|
|
22
|
+
icon: shield-check
|
|
23
|
+
name:
|
|
24
|
+
en: Roles
|
|
25
|
+
pt: Cargos
|
|
26
|
+
slug: /roles
|
|
27
|
+
relations:
|
|
28
|
+
role:
|
|
29
|
+
- where:
|
|
30
|
+
slug: admin
|
|
21
31
|
- url: /configurations
|
|
22
32
|
icon: settings-2
|
|
23
33
|
name:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hed-hog/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.76",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"sharp": "^0.34.2",
|
|
30
30
|
"speakeasy": "^2.0.0",
|
|
31
31
|
"uuid": "^11.1.0",
|
|
32
|
-
"@hed-hog/api-mail": "0.0.7",
|
|
33
32
|
"@hed-hog/api-pagination": "0.0.4",
|
|
34
|
-
"@hed-hog/api-prisma": "0.0.4",
|
|
35
33
|
"@hed-hog/types": "0.0.1",
|
|
34
|
+
"@hed-hog/api-mail": "0.0.7",
|
|
35
|
+
"@hed-hog/api-prisma": "0.0.4",
|
|
36
36
|
"@hed-hog/api-locale": "0.0.10",
|
|
37
37
|
"@hed-hog/api": "0.0.3"
|
|
38
38
|
},
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import { getLocaleText
|
|
2
|
-
import { IsString } from 'class-validator';
|
|
1
|
+
import { getLocaleText } from '@hed-hog/api-locale';
|
|
2
|
+
import { IsNotEmpty, IsObject, IsString } from 'class-validator';
|
|
3
3
|
|
|
4
|
-
export class CreateDTO
|
|
4
|
+
export class CreateDTO {
|
|
5
5
|
@IsString({ message: (args) => getLocaleText('validation.slugMustBeString', args.value) })
|
|
6
6
|
slug: string;
|
|
7
|
+
|
|
8
|
+
@IsObject({
|
|
9
|
+
message: (args) =>
|
|
10
|
+
getLocaleText('validation.localeMustBeObject', args.value),
|
|
11
|
+
})
|
|
12
|
+
@IsNotEmpty({
|
|
13
|
+
message: (args) => getLocaleText('validation.localeRequired', args.value),
|
|
14
|
+
})
|
|
15
|
+
locale: Record<string, { name: string; description: string }>;
|
|
7
16
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Role } from '@hed-hog/api';
|
|
2
|
+
import { Locale } from '@hed-hog/api-locale';
|
|
1
3
|
import { Pagination } from '@hed-hog/api-pagination';
|
|
2
4
|
import {
|
|
3
5
|
Body,
|
|
@@ -9,12 +11,11 @@ import {
|
|
|
9
11
|
ParseIntPipe,
|
|
10
12
|
Patch,
|
|
11
13
|
Post,
|
|
14
|
+
Query,
|
|
12
15
|
forwardRef,
|
|
13
16
|
} from '@nestjs/common';
|
|
14
17
|
import { DeleteDTO } from '../dto/delete.dto';
|
|
15
18
|
import { UpdateIdsDTO } from '../dto/update-ids.dto';
|
|
16
|
-
import { Locale } from '@hed-hog/api-locale';
|
|
17
|
-
import { Role } from '@hed-hog/api';
|
|
18
19
|
import { CreateDTO } from './dto/create.dto';
|
|
19
20
|
import { UpdateDTO } from './dto/update.dto';
|
|
20
21
|
import { RoleService } from './role.service';
|
|
@@ -29,7 +30,7 @@ export class RoleController {
|
|
|
29
30
|
|
|
30
31
|
@Get()
|
|
31
32
|
async list(@Pagination() paginationParams, @Locale() locale) {
|
|
32
|
-
return this.roleService.list(
|
|
33
|
+
return this.roleService.list(paginationParams, locale);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
@Get(':roleId/user')
|
|
@@ -53,8 +54,11 @@ export class RoleController {
|
|
|
53
54
|
async listRoutes(
|
|
54
55
|
@Pagination() paginationParams,
|
|
55
56
|
@Param('roleId', ParseIntPipe) roleId: number,
|
|
57
|
+
@Query('search') search?: string,
|
|
58
|
+
@Query('searchType') searchType?: 'contains' | 'startsWith' | 'endsWith',
|
|
59
|
+
@Query('method') method?: string,
|
|
56
60
|
) {
|
|
57
|
-
return this.roleService.listRoutes(roleId, paginationParams);
|
|
61
|
+
return this.roleService.listRoutes(roleId, paginationParams, search, searchType, method);
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
@Get(':roleId/screen')
|
|
@@ -99,8 +103,8 @@ export class RoleController {
|
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
@Get(':roleId')
|
|
102
|
-
async show(@Param('roleId', ParseIntPipe) roleId: number
|
|
103
|
-
return this.roleService.get(
|
|
106
|
+
async show(@Param('roleId', ParseIntPipe) roleId: number) {
|
|
107
|
+
return this.roleService.get(roleId);
|
|
104
108
|
}
|
|
105
109
|
|
|
106
110
|
@Post()
|
|
@@ -113,10 +117,7 @@ export class RoleController {
|
|
|
113
117
|
@Param('roleId', ParseIntPipe) roleId: number,
|
|
114
118
|
@Body() data: UpdateDTO,
|
|
115
119
|
) {
|
|
116
|
-
return this.roleService.update(
|
|
117
|
-
id: roleId,
|
|
118
|
-
data,
|
|
119
|
-
});
|
|
120
|
+
return this.roleService.update(roleId, data);
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
@Delete()
|
package/src/role/role.service.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getWithLocale } from '@hed-hog/api';
|
|
2
1
|
import { LocaleService, getLocaleText } from '@hed-hog/api-locale';
|
|
3
2
|
import { PaginationDTO, PaginationService } from '@hed-hog/api-pagination';
|
|
4
3
|
import { PrismaService } from '@hed-hog/api-prisma';
|
|
@@ -143,11 +142,43 @@ export class RoleService {
|
|
|
143
142
|
);
|
|
144
143
|
}
|
|
145
144
|
|
|
146
|
-
async listRoutes(
|
|
145
|
+
async listRoutes(
|
|
146
|
+
roleId: number,
|
|
147
|
+
paginationParams: PaginationDTO,
|
|
148
|
+
search?: string,
|
|
149
|
+
searchType?: 'contains' | 'startsWith' | 'endsWith',
|
|
150
|
+
method?: string,
|
|
151
|
+
) {
|
|
152
|
+
const whereClause: any = {};
|
|
153
|
+
|
|
154
|
+
// Filtro de busca por URL
|
|
155
|
+
if (search) {
|
|
156
|
+
if (searchType === 'startsWith') {
|
|
157
|
+
whereClause.url = {
|
|
158
|
+
startsWith: search,
|
|
159
|
+
};
|
|
160
|
+
} else if (searchType === 'endsWith') {
|
|
161
|
+
whereClause.url = {
|
|
162
|
+
endsWith: search,
|
|
163
|
+
};
|
|
164
|
+
} else {
|
|
165
|
+
// contains (padrão)
|
|
166
|
+
whereClause.url = {
|
|
167
|
+
contains: search,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Filtro por método HTTP
|
|
173
|
+
if (method && method !== 'all') {
|
|
174
|
+
whereClause.method = method;
|
|
175
|
+
}
|
|
176
|
+
|
|
147
177
|
return this.paginationService.paginate(
|
|
148
178
|
this.prismaService.route,
|
|
149
179
|
paginationParams,
|
|
150
180
|
{
|
|
181
|
+
where: whereClause,
|
|
151
182
|
include: {
|
|
152
183
|
role_route: {
|
|
153
184
|
where: {
|
|
@@ -198,77 +229,208 @@ export class RoleService {
|
|
|
198
229
|
);
|
|
199
230
|
}
|
|
200
231
|
|
|
201
|
-
|
|
202
|
-
const
|
|
232
|
+
async list(paginationParams, locale: string) {
|
|
233
|
+
const localeRecord = await this.localeService.getByCode(locale);
|
|
234
|
+
if (!localeRecord) {
|
|
235
|
+
throw new Error(getLocaleText('localeNotFound', locale, `Locale ${locale} not found`).replace('{{locale}}', locale));
|
|
236
|
+
}
|
|
237
|
+
const localeId = localeRecord.id;
|
|
203
238
|
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
);
|
|
239
|
+
const searchRaw = (paginationParams.search ?? '').toString().trim();
|
|
240
|
+
const hasSearch = searchRaw.length > 0;
|
|
241
|
+
const like = `%${searchRaw.toLowerCase()}%`;
|
|
208
242
|
|
|
209
|
-
|
|
210
|
-
this.prismaService
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
243
|
+
const rowsQuery = hasSearch
|
|
244
|
+
? this.prismaService.$queryRaw`
|
|
245
|
+
SELECT
|
|
246
|
+
f.id AS role_id,
|
|
247
|
+
f.slug,
|
|
248
|
+
fl.locale_id,
|
|
249
|
+
fl.name,
|
|
250
|
+
fl.description,
|
|
251
|
+
(
|
|
252
|
+
SELECT json_agg(json_build_object('code', l.code, 'name', l.name))
|
|
253
|
+
FROM role_locale fl2
|
|
254
|
+
JOIN locale l ON l.id = fl2.locale_id
|
|
255
|
+
WHERE fl2.role_id = f.id
|
|
256
|
+
AND l.enabled = true
|
|
257
|
+
AND fl2.name IS NOT NULL
|
|
258
|
+
AND fl2.name != ''
|
|
259
|
+
AND fl2.description IS NOT NULL
|
|
260
|
+
AND fl2.description != ''
|
|
261
|
+
) AS available_locales
|
|
262
|
+
FROM role AS f
|
|
263
|
+
JOIN role_locale AS fl
|
|
264
|
+
ON fl.role_id = f.id
|
|
265
|
+
WHERE fl.locale_id = ${localeId}
|
|
266
|
+
AND (
|
|
267
|
+
LOWER(fl.name) LIKE ${like}
|
|
268
|
+
OR LOWER(fl.description) LIKE ${like}
|
|
269
|
+
)
|
|
270
|
+
ORDER BY f.id DESC
|
|
271
|
+
LIMIT ${paginationParams.take}
|
|
272
|
+
OFFSET ${paginationParams.skip}
|
|
273
|
+
`
|
|
274
|
+
: this.prismaService.$queryRaw`
|
|
275
|
+
SELECT
|
|
276
|
+
f.id AS role_id,
|
|
277
|
+
f.slug,
|
|
278
|
+
fl.locale_id,
|
|
279
|
+
fl.name,
|
|
280
|
+
fl.description,
|
|
281
|
+
(
|
|
282
|
+
SELECT json_agg(json_build_object('code', l.code, 'name', l.name))
|
|
283
|
+
FROM role_locale fl2
|
|
284
|
+
JOIN locale l ON l.id = fl2.locale_id
|
|
285
|
+
WHERE fl2.role_id = f.id
|
|
286
|
+
AND l.enabled = true
|
|
287
|
+
AND fl2.name IS NOT NULL
|
|
288
|
+
AND fl2.name != ''
|
|
289
|
+
AND fl2.description IS NOT NULL
|
|
290
|
+
AND fl2.description != ''
|
|
291
|
+
) AS available_locales
|
|
292
|
+
FROM role AS f
|
|
293
|
+
JOIN role_locale AS fl
|
|
294
|
+
ON fl.role_id = f.id
|
|
295
|
+
WHERE fl.locale_id = ${localeId}
|
|
296
|
+
ORDER BY f.id DESC
|
|
297
|
+
LIMIT ${paginationParams.take}
|
|
298
|
+
OFFSET ${paginationParams.skip}
|
|
299
|
+
`;
|
|
300
|
+
|
|
301
|
+
const countQuery = this.prismaService.role.count({
|
|
302
|
+
where: {
|
|
303
|
+
role_locale: { some: { locale_id: localeId } },
|
|
304
|
+
...(hasSearch && {
|
|
305
|
+
OR: [
|
|
306
|
+
{ role_locale: { some: { locale_id: localeId, name: { contains: searchRaw, mode: 'insensitive' } } } },
|
|
307
|
+
{ role_locale: { some: { locale_id: localeId, description: { contains: searchRaw, mode: 'insensitive' } } } },
|
|
308
|
+
],
|
|
309
|
+
}),
|
|
229
310
|
},
|
|
230
|
-
|
|
231
|
-
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
const [rows, total] = await Promise.all([rowsQuery, countQuery]);
|
|
314
|
+
const mappedRows = (rows as any[]).map((row) => ({
|
|
315
|
+
...row,
|
|
316
|
+
available_locales: row.available_locales || [],
|
|
317
|
+
}));
|
|
318
|
+
|
|
319
|
+
const pageSize = paginationParams.take;
|
|
320
|
+
const page = Math.floor(paginationParams.skip / pageSize) + 1;
|
|
321
|
+
const lastPage = Math.max(1, Math.ceil(total / pageSize));
|
|
322
|
+
const prev = page > 1 ? page - 1 : null;
|
|
323
|
+
const next = page < lastPage ? page + 1 : null;
|
|
324
|
+
|
|
325
|
+
return {
|
|
326
|
+
data: mappedRows,
|
|
327
|
+
total,
|
|
328
|
+
page,
|
|
329
|
+
pageSize,
|
|
330
|
+
prev,
|
|
331
|
+
next,
|
|
332
|
+
lastPage,
|
|
333
|
+
};
|
|
232
334
|
}
|
|
233
335
|
|
|
234
|
-
async get(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
where: {
|
|
243
|
-
locale: {
|
|
244
|
-
enabled: true,
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
select: {
|
|
248
|
-
name: true,
|
|
249
|
-
description: true,
|
|
250
|
-
locale: {
|
|
251
|
-
select: {
|
|
252
|
-
code: true,
|
|
253
|
-
},
|
|
254
|
-
},
|
|
336
|
+
async get(roleId: number) {
|
|
337
|
+
const role = await this.prismaService.role.findUnique({
|
|
338
|
+
where: { id: roleId },
|
|
339
|
+
include: {
|
|
340
|
+
role_locale: {
|
|
341
|
+
include: {
|
|
342
|
+
locale: {
|
|
343
|
+
select: { code: true },
|
|
255
344
|
},
|
|
256
345
|
},
|
|
257
346
|
},
|
|
258
|
-
}
|
|
259
|
-
);
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
if (!role) {
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const localeData = role.role_locale.reduce((acc, item) => {
|
|
355
|
+
const localeCode = item.locale.code;
|
|
356
|
+
acc[localeCode] = {
|
|
357
|
+
name: item.name,
|
|
358
|
+
description: item.description,
|
|
359
|
+
};
|
|
360
|
+
return acc;
|
|
361
|
+
}, {} as Record<string, { name: string; description: string }>);
|
|
362
|
+
|
|
363
|
+
return {
|
|
364
|
+
...role,
|
|
365
|
+
locale: localeData,
|
|
366
|
+
};
|
|
260
367
|
}
|
|
261
368
|
|
|
262
|
-
async create(
|
|
263
|
-
|
|
264
|
-
|
|
369
|
+
async create(body: CreateDTO) {
|
|
370
|
+
const { locale, slug } = body;
|
|
371
|
+
|
|
372
|
+
const role = await this.prismaService.role.create({
|
|
373
|
+
data: { slug },
|
|
265
374
|
});
|
|
375
|
+
|
|
376
|
+
if (locale) {
|
|
377
|
+
await Promise.all(
|
|
378
|
+
Object.entries(locale).map(async ([localeCode, localeData]) => {
|
|
379
|
+
const localeRecord = await this.localeService.getByCode(localeCode);
|
|
380
|
+
|
|
381
|
+
await this.prismaService.role_locale.create({
|
|
382
|
+
data: {
|
|
383
|
+
role_id: role.id,
|
|
384
|
+
locale_id: localeRecord.id,
|
|
385
|
+
name: localeData.name,
|
|
386
|
+
description: localeData.description,
|
|
387
|
+
},
|
|
388
|
+
});
|
|
389
|
+
})
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return this.get(role.id);
|
|
266
394
|
}
|
|
267
395
|
|
|
268
|
-
async update(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
396
|
+
async update(id: number, body: UpdateDTO) {
|
|
397
|
+
const { locale } = body;
|
|
398
|
+
|
|
399
|
+
if (locale) {
|
|
400
|
+
await Promise.all(
|
|
401
|
+
Object.entries(locale).map(async ([localeCode, localeData]) => {
|
|
402
|
+
const localeRecord = await this.localeService.getByCode(localeCode);
|
|
403
|
+
|
|
404
|
+
const existing = await this.prismaService.role_locale.findFirst({
|
|
405
|
+
where: {
|
|
406
|
+
role_id: id,
|
|
407
|
+
locale_id: localeRecord.id,
|
|
408
|
+
},
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
if (existing) {
|
|
412
|
+
await this.prismaService.role_locale.update({
|
|
413
|
+
where: { id: existing.id },
|
|
414
|
+
data: {
|
|
415
|
+
name: localeData.name,
|
|
416
|
+
description: localeData.description,
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
} else {
|
|
420
|
+
await this.prismaService.role_locale.create({
|
|
421
|
+
data: {
|
|
422
|
+
role_id: id,
|
|
423
|
+
locale_id: localeRecord.id,
|
|
424
|
+
name: localeData.name,
|
|
425
|
+
description: localeData.description,
|
|
426
|
+
},
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
})
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return this.get(id);
|
|
272
434
|
}
|
|
273
435
|
|
|
274
436
|
async delete({ ids }: DeleteDTO, locale: string = 'en'):Promise<{count:number}> {
|