@hedhog/admin 0.0.11 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/auth/guards/auth.guard.d.ts.map +1 -1
- package/dist/auth/guards/auth.guard.js +2 -2
- package/dist/auth/guards/auth.guard.js.map +1 -1
- package/dist/permission/guards/permission.guard.d.ts.map +1 -1
- package/dist/permission/guards/permission.guard.js +4 -1
- package/dist/permission/guards/permission.guard.js.map +1 -1
- package/dist/permission/permission.controller.js +1 -1
- package/dist/user/dto/update-roles.dto.d.ts +4 -0
- package/dist/user/dto/update-roles.dto.d.ts.map +1 -0
- package/dist/user/dto/update-roles.dto.js +24 -0
- package/dist/user/dto/update-roles.dto.js.map +1 -0
- package/dist/user/user.controller.d.ts +3 -0
- package/dist/user/user.controller.d.ts.map +1 -1
- package/dist/user/user.controller.js +25 -0
- package/dist/user/user.controller.js.map +1 -1
- package/dist/user/user.service.d.ts +3 -0
- package/dist/user/user.service.d.ts.map +1 -1
- package/dist/user/user.service.js +31 -0
- package/dist/user/user.service.js.map +1 -1
- package/package.json +1 -1
- package/src/migrations/migrate-04.ts +8 -0
- package/src/migrations/migrate-14.ts +10 -0
- package/src/migrations/migrate-16.ts +37 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"auth.guard.d.ts","sourceRoot":"","sources":["../../../src/auth/guards/auth.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAGjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,qBACa,SAAU,YAAW,WAAW;IAEzC,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,SAAS;gBADT,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,SAAS;IAGxB,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAyB9D,OAAO,CAAC,sBAAsB;
|
1
|
+
{"version":3,"file":"auth.guard.d.ts","sourceRoot":"","sources":["../../../src/auth/guards/auth.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAGjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,qBACa,SAAU,YAAW,WAAW;IAEzC,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,SAAS;gBADT,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,SAAS;IAGxB,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAyB9D,OAAO,CAAC,sBAAsB;CAK/B"}
|
@@ -36,8 +36,8 @@ let AuthGuard = class AuthGuard {
|
|
36
36
|
const payload = await this.auth.verifyToken(token);
|
37
37
|
request['auth'] = payload;
|
38
38
|
}
|
39
|
-
catch (
|
40
|
-
throw new common_1.UnauthorizedException();
|
39
|
+
catch (error) {
|
40
|
+
throw new common_1.UnauthorizedException(error);
|
41
41
|
}
|
42
42
|
return true;
|
43
43
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../../../src/auth/guards/auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAKwB;AACxB,uCAAyC;AAEzC,kDAA8C;AAC9C,qEAA+D;AAGxD,IAAM,SAAS,GAAf,MAAM,SAAS;IACpB,YACU,IAAiB,EACjB,SAAoB;QADpB,SAAI,GAAJ,IAAI,CAAa;QACjB,cAAS,GAAT,SAAS,CAAW;IAC3B,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAU,gCAAa,EAAE;YACxE,OAAO,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,QAAQ,EAAE;SACnB,C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,EAAE,CAAC;QACpC,CAAC;QACD,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YAEnD,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,8BAAqB,CAAC,KAAK,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,sBAAsB,CAAC,OAAgB;;QAC7C,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,MAAA,MAAA,OAAO,CAAC,OAAO,CAAC,aAAa,0CAAE,KAAK,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC;QAEtE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/C,CAAC;CACF,CAAA;AApCY,8BAAS;oBAAT,SAAS;IADrB,IAAA,mBAAU,GAAE;qCAGK,0BAAW;QACN,gBAAS;GAHnB,SAAS,CAoCrB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"permission.guard.d.ts","sourceRoot":"","sources":["../../../src/permission/guards/permission.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAMjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,qBACa,eAAgB,YAAW,WAAW;IAE/C,OAAO,CAAC,SAAS;IAEjB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAFf,SAAS,EAAE,SAAS,EAEX,MAAM,EAAE,aAAa;IAGlC,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"permission.guard.d.ts","sourceRoot":"","sources":["../../../src/permission/guards/permission.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAMjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,qBACa,eAAgB,YAAW,WAAW;IAE/C,OAAO,CAAC,SAAS;IAEjB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAFf,SAAS,EAAE,SAAS,EAEX,MAAM,EAAE,aAAa;IAGlC,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAoF9D,OAAO,CAAC,sBAAsB;CAI/B"}
|
@@ -35,7 +35,10 @@ let PermissionGuard = class PermissionGuard {
|
|
35
35
|
const controllerPath = this.reflector.get('path', controller) || '';
|
36
36
|
const methodPath = this.reflector.get('path', handler) || '';
|
37
37
|
const requestMethod = this.reflector.get(constants_1.METHOD_METADATA, handler);
|
38
|
-
|
38
|
+
let fullPath = `/${controllerPath}/${methodPath}`.replace(/\/+/g, '/');
|
39
|
+
if (fullPath.endsWith('/')) {
|
40
|
+
fullPath = fullPath.slice(0, -1);
|
41
|
+
}
|
39
42
|
const token = this.extractTokenFromHeader(request);
|
40
43
|
if (!token) {
|
41
44
|
throw new common_1.UnauthorizedException();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"permission.guard.js","sourceRoot":"","sources":["../../../src/permission/guards/permission.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAQwB;AAExB,uCAAyC;AACzC,wDAA2D;AAC3D,6EAAqE;AACrE,2CAA+C;AAGxC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YACU,SAAoB,EAEX,MAAqB;QAF9B,cAAS,GAAT,SAAS,CAAW;QAEX,WAAM,GAAN,MAAM,CAAe;IACrC,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,OAAyB;;Q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,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,sBAAa,CAAC,CAAC,CAAA;qCADrB,gBAAS;QAEH,sBAAa;GAJ7B,eAAe,CA+F3B"}
|
@@ -72,7 +72,7 @@ __decorate([
|
|
72
72
|
__decorate([
|
73
73
|
(0, common_1.UseGuards)(auth_guard_1.AuthGuard),
|
74
74
|
(0, common_1.Patch)(':permissionId'),
|
75
|
-
__param(0, (0, common_1.Param)('
|
75
|
+
__param(0, (0, common_1.Param)('permissionId', common_1.ParseIntPipe)),
|
76
76
|
__param(1, (0, common_1.Body)()),
|
77
77
|
__metadata("design:type", Function),
|
78
78
|
__metadata("design:paramtypes", [Number, update_dto_1.UpdateDTO]),
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"update-roles.dto.d.ts","sourceRoot":"","sources":["../../../src/user/dto/update-roles.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,cAAc;IAKzB,GAAG,EAAE,MAAM,EAAE,CAAC;CACf"}
|
@@ -0,0 +1,24 @@
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.UpdateRolesDTO = void 0;
|
13
|
+
const class_validator_1 = require("class-validator");
|
14
|
+
class UpdateRolesDTO {
|
15
|
+
}
|
16
|
+
exports.UpdateRolesDTO = UpdateRolesDTO;
|
17
|
+
__decorate([
|
18
|
+
(0, class_validator_1.IsInt)({
|
19
|
+
each: true,
|
20
|
+
}),
|
21
|
+
(0, class_validator_1.IsArray)(),
|
22
|
+
__metadata("design:type", Array)
|
23
|
+
], UpdateRolesDTO.prototype, "ids", void 0);
|
24
|
+
//# sourceMappingURL=update-roles.dto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"update-roles.dto.js","sourceRoot":"","sources":["../../../src/user/dto/update-roles.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAiD;AAEjD,MAAa,cAAc;CAM1B;AAND,wCAMC;AADC;IAJC,IAAA,uBAAK,EAAC;QACL,IAAI,EAAE,IAAI;KACX,CAAC;IACD,IAAA,yBAAO,GAAE;;2CACI"}
|
@@ -2,10 +2,13 @@ import { CreateDTO } from './dto/create.dto';
|
|
2
2
|
import { DeleteDTO } from './dto/delete.dto';
|
3
3
|
import { UpdateDTO } from './dto/update.dto';
|
4
4
|
import { UserService } from './user.service';
|
5
|
+
import { UpdateRolesDTO } from './dto/update-roles.dto';
|
5
6
|
export declare class UserController {
|
6
7
|
private readonly userService;
|
7
8
|
constructor(userService: UserService);
|
8
9
|
getUsers(paginationParams: any): Promise<import("@hedhog/pagination").PaginatedResult<unknown>>;
|
10
|
+
listRoles(userId: number, paginationParams: any): Promise<import("@hedhog/pagination").PaginatedResult<unknown>>;
|
11
|
+
updateRoles(userId: number, data: UpdateRolesDTO): Promise<any>;
|
9
12
|
show(userId: number): Promise<any>;
|
10
13
|
create(data: CreateDTO): Promise<any>;
|
11
14
|
update(userId: number, data: UpdateDTO): Promise<any>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"user.controller.d.ts","sourceRoot":"","sources":["../../src/user/user.controller.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
1
|
+
{"version":3,"file":"user.controller.d.ts","sourceRoot":"","sources":["../../src/user/user.controller.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,qBAEa,cAAc;IAGvB,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,WAAW;IAKrC,QAAQ,CAAe,gBAAgB,KAAA;IAMvC,SAAS,CACkB,MAAM,EAAE,MAAM,EAC/B,gBAAgB,KAAA;IAO1B,WAAW,CACgB,MAAM,EAAE,MAAM,EACrC,IAAI,EAAE,cAAc;IAOxB,IAAI,CAAgC,MAAM,EAAE,MAAM;IAMxD,MAAM,CAAS,IAAI,EAAE,SAAS;IAMxB,MAAM,CACqB,MAAM,EAAE,MAAM,EACrC,IAAI,EAAE,SAAS;IAUnB,MAAM,CAAS,IAAI,EAAE,SAAS;CAGrC"}
|
@@ -21,6 +21,7 @@ const update_dto_1 = require("./dto/update.dto");
|
|
21
21
|
const user_service_1 = require("./user.service");
|
22
22
|
const permission_decorator_1 = require("../permission/decorators/permission.decorator");
|
23
23
|
const auth_guard_1 = require("../auth/guards/auth.guard");
|
24
|
+
const update_roles_dto_1 = require("./dto/update-roles.dto");
|
24
25
|
let UserController = class UserController {
|
25
26
|
constructor(userService) {
|
26
27
|
this.userService = userService;
|
@@ -28,6 +29,12 @@ let UserController = class UserController {
|
|
28
29
|
async getUsers(paginationParams) {
|
29
30
|
return this.userService.getUsers(paginationParams);
|
30
31
|
}
|
32
|
+
async listRoles(userId, paginationParams) {
|
33
|
+
return this.userService.listRoles(userId, paginationParams);
|
34
|
+
}
|
35
|
+
async updateRoles(userId, data) {
|
36
|
+
return this.userService.updateRoles(userId, data);
|
37
|
+
}
|
31
38
|
async show(userId) {
|
32
39
|
return this.userService.get(userId);
|
33
40
|
}
|
@@ -53,6 +60,24 @@ __decorate([
|
|
53
60
|
__metadata("design:paramtypes", [Object]),
|
54
61
|
__metadata("design:returntype", Promise)
|
55
62
|
], UserController.prototype, "getUsers", null);
|
63
|
+
__decorate([
|
64
|
+
(0, common_1.UseGuards)(auth_guard_1.AuthGuard),
|
65
|
+
(0, common_1.Get)(':userId/roles'),
|
66
|
+
__param(0, (0, common_1.Param)('userId', common_1.ParseIntPipe)),
|
67
|
+
__param(1, (0, pagination_1.Pagination)()),
|
68
|
+
__metadata("design:type", Function),
|
69
|
+
__metadata("design:paramtypes", [Number, Object]),
|
70
|
+
__metadata("design:returntype", Promise)
|
71
|
+
], UserController.prototype, "listRoles", null);
|
72
|
+
__decorate([
|
73
|
+
(0, common_1.UseGuards)(auth_guard_1.AuthGuard),
|
74
|
+
(0, common_1.Patch)(':userId/roles'),
|
75
|
+
__param(0, (0, common_1.Param)('userId', common_1.ParseIntPipe)),
|
76
|
+
__param(1, (0, common_1.Body)()),
|
77
|
+
__metadata("design:type", Function),
|
78
|
+
__metadata("design:paramtypes", [Number, update_roles_dto_1.UpdateRolesDTO]),
|
79
|
+
__metadata("design:returntype", Promise)
|
80
|
+
], UserController.prototype, "updateRoles", null);
|
56
81
|
__decorate([
|
57
82
|
(0, common_1.UseGuards)(auth_guard_1.AuthGuard),
|
58
83
|
(0, common_1.Get)(':userId'),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"user.controller.js","sourceRoot":"","sources":["../../src/user/user.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;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CAAC;IACpB,IAAA,eAAM,GAAE;IACK,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAO,sBAAS;;4CAEnC;yBA1DU,cAAc;IAF1B,IAAA,iCAAU,GAAE;IACZ,IAAA,mBAAU,EAAC,OAAO,CAAC;IAGf,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAW,CAAC,CAAC,CAAA;qCACR,0BAAW;GAHhC,cAAc,CA2D1B"}
|
@@ -3,10 +3,13 @@ import { PrismaService } from '@hedhog/prisma';
|
|
3
3
|
import { CreateDTO } from './dto/create.dto';
|
4
4
|
import { DeleteDTO } from './dto/delete.dto';
|
5
5
|
import { UpdateDTO } from './dto/update.dto';
|
6
|
+
import { UpdateRolesDTO } from './dto/update-roles.dto';
|
6
7
|
export declare class UserService {
|
7
8
|
private readonly prismaService;
|
8
9
|
private readonly paginationService;
|
9
10
|
constructor(prismaService: PrismaService, paginationService: PaginationService);
|
11
|
+
listRoles(userId: number, paginationParams: PaginationDTO): Promise<import("@hedhog/pagination").PaginatedResult<unknown>>;
|
12
|
+
updateRoles(userId: number, { ids }: UpdateRolesDTO): Promise<any>;
|
10
13
|
getUsers(paginationParams: PaginationDTO): Promise<import("@hedhog/pagination").PaginatedResult<unknown>>;
|
11
14
|
get(userId: number): Promise<any>;
|
12
15
|
hashPassword(password: string): Promise<string>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../src/user/user.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAS/C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;
|
1
|
+
{"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../src/user/user.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAS/C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,qBACa,WAAW;IAGpB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBAFjB,aAAa,EAAE,aAAa,EAE5B,iBAAiB,EAAE,iBAAiB;IAGjD,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa;IAoBzD,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,cAAc;IAkBnD,QAAQ,CAAC,gBAAgB,EAAE,aAAa;IAkBxC,GAAG,CAAC,MAAM,EAAE,MAAM;IAIlB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK/C,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,SAAS;IAY3C,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE;IAOpD,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS;CAoBhC"}
|
@@ -23,6 +23,37 @@ let UserService = class UserService {
|
|
23
23
|
this.prismaService = prismaService;
|
24
24
|
this.paginationService = paginationService;
|
25
25
|
}
|
26
|
+
async listRoles(userId, paginationParams) {
|
27
|
+
return this.paginationService.paginate(this.prismaService.roles, paginationParams, {
|
28
|
+
include: {
|
29
|
+
role_users: {
|
30
|
+
where: {
|
31
|
+
user_id: userId,
|
32
|
+
},
|
33
|
+
select: {
|
34
|
+
user_id: true,
|
35
|
+
role_id: true,
|
36
|
+
},
|
37
|
+
},
|
38
|
+
},
|
39
|
+
});
|
40
|
+
}
|
41
|
+
async updateRoles(userId, { ids }) {
|
42
|
+
await this.prismaService.roles.deleteMany({
|
43
|
+
where: {
|
44
|
+
user_id: userId,
|
45
|
+
},
|
46
|
+
});
|
47
|
+
return this.prismaService.roles.createMany({
|
48
|
+
data: ids.map((role) => {
|
49
|
+
return {
|
50
|
+
user_id: userId,
|
51
|
+
role_id: role,
|
52
|
+
};
|
53
|
+
}),
|
54
|
+
skipDuplicates: true,
|
55
|
+
});
|
56
|
+
}
|
26
57
|
async getUsers(paginationParams) {
|
27
58
|
const fields = ['name', 'email'];
|
28
59
|
const OR = this.prismaService.createInsensitiveSearch(fields, paginationParams);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../src/user/user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAsE;AACtE,2CAA+C;AAC/C,2CAKwB;AACxB,mCAAuC;AACvC,+DAAyD;
|
1
|
+
{"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../src/user/user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAsE;AACtE,2CAA+C;AAC/C,2CAKwB;AACxB,mCAAuC;AACvC,+DAAyD;AAOlD,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,YAEmB,aAA4B,EAE5B,iBAAoC;QAFpC,kBAAa,GAAb,aAAa,CAAe;QAE5B,sBAAiB,GAAjB,iBAAiB,CAAmB;IACpD,CAAC;IAEJ,KAAK,CAAC,SAAS,CAAC,MAAc,EAAE,gBAA+B;QAC7D,OAAO,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CACpC,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Aa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,8BAAiB,CAAC,CAAC,CAAA;qCADZ,sBAAa;QAET,8BAAiB;GAL5C,WAAW,CAgHvB"}
|
package/package.json
CHANGED
@@ -137,6 +137,10 @@ export class Migrate implements MigrationInterface {
|
|
137
137
|
url: '/users/:userId',
|
138
138
|
method: 'GET',
|
139
139
|
},
|
140
|
+
{
|
141
|
+
url: '/users/:userId/roles',
|
142
|
+
method: 'GET',
|
143
|
+
},
|
140
144
|
{
|
141
145
|
url: '/users',
|
142
146
|
method: 'POST',
|
@@ -145,6 +149,10 @@ export class Migrate implements MigrationInterface {
|
|
145
149
|
url: '/users/:userId',
|
146
150
|
method: 'PATCH',
|
147
151
|
},
|
152
|
+
{
|
153
|
+
url: '/users/:userId/roles',
|
154
|
+
method: 'PATCH',
|
155
|
+
},
|
148
156
|
{
|
149
157
|
url: '/users',
|
150
158
|
method: 'DELETE',
|
@@ -20,6 +20,16 @@ export class Migrate implements MigrationInterface {
|
|
20
20
|
.execute();
|
21
21
|
}
|
22
22
|
|
23
|
+
await queryRunner.manager
|
24
|
+
.createQueryBuilder()
|
25
|
+
.insert()
|
26
|
+
.into('role_routes')
|
27
|
+
.values({
|
28
|
+
role_id: 2,
|
29
|
+
route_id: 3,
|
30
|
+
})
|
31
|
+
.execute();
|
32
|
+
|
23
33
|
const routesScreens = await queryRunner.manager
|
24
34
|
.createQueryBuilder()
|
25
35
|
.select()
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm';
|
2
|
+
|
3
|
+
export class Migrate implements MigrationInterface {
|
4
|
+
async up(queryRunner: QueryRunner) {
|
5
|
+
const menus = await queryRunner.manager
|
6
|
+
.createQueryBuilder()
|
7
|
+
.select()
|
8
|
+
.from('menus', 'm')
|
9
|
+
.execute();
|
10
|
+
|
11
|
+
await queryRunner.manager
|
12
|
+
.createQueryBuilder()
|
13
|
+
.insert()
|
14
|
+
.into('role_menus', ['role_id', 'menu_id'])
|
15
|
+
.values(
|
16
|
+
menus.map((menu) => ({
|
17
|
+
role_id: 1,
|
18
|
+
menu_id: menu.id,
|
19
|
+
})),
|
20
|
+
)
|
21
|
+
.execute();
|
22
|
+
|
23
|
+
await queryRunner.manager
|
24
|
+
.createQueryBuilder()
|
25
|
+
.insert()
|
26
|
+
.into('role_menus', ['role_id', 'menu_id'])
|
27
|
+
.values({
|
28
|
+
role_id: 2,
|
29
|
+
menu_id: 1,
|
30
|
+
});
|
31
|
+
}
|
32
|
+
|
33
|
+
async down(queryRunner: QueryRunner) {
|
34
|
+
await queryRunner.manager.delete('role_menus', { role_id: 1 });
|
35
|
+
await queryRunner.manager.delete('role_menus', { role_id: 2 });
|
36
|
+
}
|
37
|
+
}
|