@hed-hog/core 0.0.74 → 0.0.75
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 +69 -3
- package/dist/role/role.controller.d.ts.map +1 -1
- package/dist/role/role.controller.js +6 -10
- package/dist/role/role.controller.js.map +1 -1
- package/dist/role/role.service.d.ts +68 -5
- package/dist/role/role.service.d.ts.map +1 -1
- package/dist/role/role.service.js +68 -22
- 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 +5 -8
- package/src/role/role.service.ts +94 -35
|
@@ -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"}
|
|
@@ -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":"AAeA,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;;;;;;;;;IAMzC,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");
|
|
@@ -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);
|
|
@@ -147,9 +144,8 @@ __decorate([
|
|
|
147
144
|
__decorate([
|
|
148
145
|
(0, common_1.Get)(':roleId'),
|
|
149
146
|
__param(0, (0, common_1.Param)('roleId', common_1.ParseIntPipe)),
|
|
150
|
-
__param(1, (0, api_locale_1.Locale)()),
|
|
151
147
|
__metadata("design:type", Function),
|
|
152
|
-
__metadata("design:paramtypes", [Number
|
|
148
|
+
__metadata("design:paramtypes", [Number]),
|
|
153
149
|
__metadata("design:returntype", Promise)
|
|
154
150
|
], RoleController.prototype, "show", null);
|
|
155
151
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.controller.js","sourceRoot":"","sources":["../../src/role/role.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4DAAqD;AACrD,2CAWwB;AACxB,kDAA8C;AAC9C,0DAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"role.controller.js","sourceRoot":"","sources":["../../src/role/role.controller.ts"],"names":[],"mappings":";;;;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cAAK,EAAC,QAAQ,EAAE,qBAAY,CAAC,CAAA;;;;0CAExC;AAGK;IADL,IAAA,aAAI,GAAE;IACO,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAO,sBAAS;;4CAEnC;AAGK;IADL,IAAA,cAAK,EAAC,SAAS,CAAC;IAEd,WAAA,IAAA,cAAK,EAAC,QAAQ,EAAE,qBAAY,CAAC,CAAA;IAC7B,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAO,sBAAS;;4CAGxB;AAGK;IADL,IAAA,eAAM,GAAE;IACK,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAO,sBAAS;;4CAEnC;yBAlGU,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,CAmG1B"}
|
|
@@ -67,12 +67,75 @@ export declare class RoleService {
|
|
|
67
67
|
next: number;
|
|
68
68
|
data: any;
|
|
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,E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AM,EAAE,gBAAgB,EAAE,aAAa;;;;;;;;;IAoB1D,WAAW,CACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,aAAa;;;;;;;;;IAgC3B,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa;;;;;;;;;IAiCpD,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");
|
|
@@ -182,38 +181,85 @@ let RoleService = class RoleService {
|
|
|
182
181
|
},
|
|
183
182
|
}, 'role_locale');
|
|
184
183
|
}
|
|
185
|
-
async get(
|
|
186
|
-
|
|
184
|
+
async get(roleId) {
|
|
185
|
+
const role = await this.prismaService.role.findUnique({
|
|
187
186
|
where: { id: roleId },
|
|
188
187
|
include: {
|
|
189
188
|
role_locale: {
|
|
190
|
-
|
|
189
|
+
include: {
|
|
191
190
|
locale: {
|
|
192
|
-
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
select: {
|
|
196
|
-
name: true,
|
|
197
|
-
description: true,
|
|
198
|
-
locale: {
|
|
199
|
-
select: {
|
|
200
|
-
code: true,
|
|
201
|
-
},
|
|
191
|
+
select: { code: true },
|
|
202
192
|
},
|
|
203
193
|
},
|
|
204
194
|
},
|
|
205
195
|
},
|
|
206
|
-
}));
|
|
207
|
-
}
|
|
208
|
-
async create({ slug }) {
|
|
209
|
-
return this.localeService.createModelWithLocale('role', 'role_id', {
|
|
210
|
-
slug,
|
|
211
196
|
});
|
|
197
|
+
if (!role) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
const localeData = role.role_locale.reduce((acc, item) => {
|
|
201
|
+
const localeCode = item.locale.code;
|
|
202
|
+
acc[localeCode] = {
|
|
203
|
+
name: item.name,
|
|
204
|
+
description: item.description,
|
|
205
|
+
};
|
|
206
|
+
return acc;
|
|
207
|
+
}, {});
|
|
208
|
+
return Object.assign(Object.assign({}, role), { locale: localeData });
|
|
212
209
|
}
|
|
213
|
-
async
|
|
214
|
-
|
|
215
|
-
|
|
210
|
+
async create(body) {
|
|
211
|
+
const { locale, slug } = body;
|
|
212
|
+
const role = await this.prismaService.role.create({
|
|
213
|
+
data: { slug },
|
|
216
214
|
});
|
|
215
|
+
if (locale) {
|
|
216
|
+
await Promise.all(Object.entries(locale).map(async ([localeCode, localeData]) => {
|
|
217
|
+
const localeRecord = await this.localeService.getByCode(localeCode);
|
|
218
|
+
await this.prismaService.role_locale.create({
|
|
219
|
+
data: {
|
|
220
|
+
role_id: role.id,
|
|
221
|
+
locale_id: localeRecord.id,
|
|
222
|
+
name: localeData.name,
|
|
223
|
+
description: localeData.description,
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
}));
|
|
227
|
+
}
|
|
228
|
+
return this.get(role.id);
|
|
229
|
+
}
|
|
230
|
+
async update(id, body) {
|
|
231
|
+
const { locale } = body;
|
|
232
|
+
if (locale) {
|
|
233
|
+
await Promise.all(Object.entries(locale).map(async ([localeCode, localeData]) => {
|
|
234
|
+
const localeRecord = await this.localeService.getByCode(localeCode);
|
|
235
|
+
const existing = await this.prismaService.role_locale.findFirst({
|
|
236
|
+
where: {
|
|
237
|
+
role_id: id,
|
|
238
|
+
locale_id: localeRecord.id,
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
if (existing) {
|
|
242
|
+
await this.prismaService.role_locale.update({
|
|
243
|
+
where: { id: existing.id },
|
|
244
|
+
data: {
|
|
245
|
+
name: localeData.name,
|
|
246
|
+
description: localeData.description,
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
await this.prismaService.role_locale.create({
|
|
252
|
+
data: {
|
|
253
|
+
role_id: id,
|
|
254
|
+
locale_id: localeRecord.id,
|
|
255
|
+
name: localeData.name,
|
|
256
|
+
description: localeData.description,
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}));
|
|
261
|
+
}
|
|
262
|
+
return this.get(id);
|
|
217
263
|
}
|
|
218
264
|
async delete({ ids }, locale = 'en') {
|
|
219
265
|
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","sourceRoot":"","sources":["../../src/role/role.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAmE;AACnE,4DAA2E;AAC3E,oDAAoD;AACpD,2CAKwB;AAOjB,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,YAEmB,aAA4B,EAE5B,iBAAoC,EAEpC,aAA4B;QAJ5B,kBAAa,GAAb,aAAa,CAAe;QAE5B,sBAAiB,GAAjB,iBAAiB,CAAmB;QAEpC,kBAAa,GAAb,aAAa,CAAe;IA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AE;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,CA4UvB"}
|
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.75",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -29,11 +29,11 @@
|
|
|
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",
|
|
33
|
+
"@hed-hog/api-mail": "0.0.7",
|
|
34
34
|
"@hed-hog/api-prisma": "0.0.4",
|
|
35
|
-
"@hed-hog/types": "0.0.1",
|
|
36
35
|
"@hed-hog/api-locale": "0.0.10",
|
|
36
|
+
"@hed-hog/types": "0.0.1",
|
|
37
37
|
"@hed-hog/api": "0.0.3"
|
|
38
38
|
},
|
|
39
39
|
"exports": {
|
|
@@ -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,
|
|
@@ -13,8 +15,6 @@ import {
|
|
|
13
15
|
} from '@nestjs/common';
|
|
14
16
|
import { DeleteDTO } from '../dto/delete.dto';
|
|
15
17
|
import { UpdateIdsDTO } from '../dto/update-ids.dto';
|
|
16
|
-
import { Locale } from '@hed-hog/api-locale';
|
|
17
|
-
import { Role } from '@hed-hog/api';
|
|
18
18
|
import { CreateDTO } from './dto/create.dto';
|
|
19
19
|
import { UpdateDTO } from './dto/update.dto';
|
|
20
20
|
import { RoleService } from './role.service';
|
|
@@ -99,8 +99,8 @@ export class RoleController {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
@Get(':roleId')
|
|
102
|
-
async show(@Param('roleId', ParseIntPipe) roleId: number
|
|
103
|
-
return this.roleService.get(
|
|
102
|
+
async show(@Param('roleId', ParseIntPipe) roleId: number) {
|
|
103
|
+
return this.roleService.get(roleId);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
@Post()
|
|
@@ -113,10 +113,7 @@ export class RoleController {
|
|
|
113
113
|
@Param('roleId', ParseIntPipe) roleId: number,
|
|
114
114
|
@Body() data: UpdateDTO,
|
|
115
115
|
) {
|
|
116
|
-
return this.roleService.update(
|
|
117
|
-
id: roleId,
|
|
118
|
-
data,
|
|
119
|
-
});
|
|
116
|
+
return this.roleService.update(roleId, data);
|
|
120
117
|
}
|
|
121
118
|
|
|
122
119
|
@Delete()
|
package/src/role/role.service.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
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';
|
|
5
4
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
BadRequestException,
|
|
6
|
+
Inject,
|
|
7
|
+
Injectable,
|
|
8
|
+
forwardRef,
|
|
10
9
|
} from '@nestjs/common';
|
|
11
10
|
import { DeleteDTO } from '../dto/delete.dto';
|
|
12
11
|
import { UpdateIdsDTO } from '../dto/update-ids.dto';
|
|
@@ -231,44 +230,104 @@ export class RoleService {
|
|
|
231
230
|
);
|
|
232
231
|
}
|
|
233
232
|
|
|
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
|
-
},
|
|
233
|
+
async get(roleId: number) {
|
|
234
|
+
const role = await this.prismaService.role.findUnique({
|
|
235
|
+
where: { id: roleId },
|
|
236
|
+
include: {
|
|
237
|
+
role_locale: {
|
|
238
|
+
include: {
|
|
239
|
+
locale: {
|
|
240
|
+
select: { code: true },
|
|
255
241
|
},
|
|
256
242
|
},
|
|
257
243
|
},
|
|
258
|
-
}
|
|
259
|
-
);
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
if (!role) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const localeData = role.role_locale.reduce((acc, item) => {
|
|
252
|
+
const localeCode = item.locale.code;
|
|
253
|
+
acc[localeCode] = {
|
|
254
|
+
name: item.name,
|
|
255
|
+
description: item.description,
|
|
256
|
+
};
|
|
257
|
+
return acc;
|
|
258
|
+
}, {} as Record<string, { name: string; description: string }>);
|
|
259
|
+
|
|
260
|
+
return {
|
|
261
|
+
...role,
|
|
262
|
+
locale: localeData,
|
|
263
|
+
};
|
|
260
264
|
}
|
|
261
265
|
|
|
262
|
-
async create(
|
|
263
|
-
|
|
264
|
-
|
|
266
|
+
async create(body: CreateDTO) {
|
|
267
|
+
const { locale, slug } = body;
|
|
268
|
+
|
|
269
|
+
const role = await this.prismaService.role.create({
|
|
270
|
+
data: { slug },
|
|
265
271
|
});
|
|
272
|
+
|
|
273
|
+
if (locale) {
|
|
274
|
+
await Promise.all(
|
|
275
|
+
Object.entries(locale).map(async ([localeCode, localeData]) => {
|
|
276
|
+
const localeRecord = await this.localeService.getByCode(localeCode);
|
|
277
|
+
|
|
278
|
+
await this.prismaService.role_locale.create({
|
|
279
|
+
data: {
|
|
280
|
+
role_id: role.id,
|
|
281
|
+
locale_id: localeRecord.id,
|
|
282
|
+
name: localeData.name,
|
|
283
|
+
description: localeData.description,
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
})
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return this.get(role.id);
|
|
266
291
|
}
|
|
267
292
|
|
|
268
|
-
async update(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
293
|
+
async update(id: number, body: UpdateDTO) {
|
|
294
|
+
const { locale } = body;
|
|
295
|
+
|
|
296
|
+
if (locale) {
|
|
297
|
+
await Promise.all(
|
|
298
|
+
Object.entries(locale).map(async ([localeCode, localeData]) => {
|
|
299
|
+
const localeRecord = await this.localeService.getByCode(localeCode);
|
|
300
|
+
|
|
301
|
+
const existing = await this.prismaService.role_locale.findFirst({
|
|
302
|
+
where: {
|
|
303
|
+
role_id: id,
|
|
304
|
+
locale_id: localeRecord.id,
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
if (existing) {
|
|
309
|
+
await this.prismaService.role_locale.update({
|
|
310
|
+
where: { id: existing.id },
|
|
311
|
+
data: {
|
|
312
|
+
name: localeData.name,
|
|
313
|
+
description: localeData.description,
|
|
314
|
+
},
|
|
315
|
+
});
|
|
316
|
+
} else {
|
|
317
|
+
await this.prismaService.role_locale.create({
|
|
318
|
+
data: {
|
|
319
|
+
role_id: id,
|
|
320
|
+
locale_id: localeRecord.id,
|
|
321
|
+
name: localeData.name,
|
|
322
|
+
description: localeData.description,
|
|
323
|
+
},
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
})
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return this.get(id);
|
|
272
331
|
}
|
|
273
332
|
|
|
274
333
|
async delete({ ids }: DeleteDTO, locale: string = 'en'):Promise<{count:number}> {
|