@hedhog/admin 0.12.2 → 0.12.4
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/auth/auth.controller.d.ts +1 -10
- package/dist/auth/auth.controller.d.ts.map +1 -1
- package/dist/auth/auth.service.d.ts +1 -10
- package/dist/auth/auth.service.d.ts.map +1 -1
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/auth/auth.service.spec.d.ts +0 -1
- package/dist/auth/auth.service.spec.js +171 -161
- package/dist/auth/auth.service.spec.js.map +1 -1
- package/dist/auth/consts/body.js +23 -23
- package/dist/menu/menu.controller.d.ts +6 -33
- package/dist/menu/menu.controller.d.ts.map +1 -1
- package/dist/menu/menu.service.d.ts +6 -33
- package/dist/menu/menu.service.d.ts.map +1 -1
- package/dist/menu/menu.service.js.map +1 -1
- package/dist/role/guards/role.guard.js.map +1 -1
- package/dist/role/role.controller.d.ts +5 -5
- package/dist/role/role.service.d.ts +5 -5
- package/dist/role/role.service.js.map +1 -1
- package/dist/route/route.controller.d.ts +6 -27
- package/dist/route/route.controller.d.ts.map +1 -1
- package/dist/route/route.service.d.ts +6 -27
- package/dist/route/route.service.d.ts.map +1 -1
- package/dist/route/route.service.js.map +1 -1
- package/dist/screen/screen.controller.d.ts +6 -24
- package/dist/screen/screen.controller.d.ts.map +1 -1
- package/dist/screen/screen.service.d.ts +6 -24
- package/dist/screen/screen.service.d.ts.map +1 -1
- package/dist/screen/screen.service.js.map +1 -1
- package/dist/user/user.controller.d.ts +5 -32
- package/dist/user/user.controller.d.ts.map +1 -1
- package/dist/user/user.service.d.ts +5 -32
- package/dist/user/user.service.d.ts.map +1 -1
- package/dist/user/user.service.js.map +1 -1
- package/dist/user/user.service.spec.d.ts +0 -1
- package/dist/user/user.service.spec.js +259 -250
- package/dist/user/user.service.spec.js.map +1 -1
- package/frontend/menu/components/create-panel.tsx.ejs +55 -0
- package/frontend/menu/components/update-panel.tsx.ejs +67 -0
- package/frontend/menu/locales/en/admin.menu.json +11 -0
- package/frontend/menu/locales/pt/admin.menu.json +11 -0
- package/frontend/menu/react-query/handlers.ts.ejs +28 -0
- package/frontend/menu/react-query/requests.ts.ejs +56 -0
- package/frontend/menu-locale/locales/en/admin.menu-locale.json +11 -0
- package/frontend/menu-locale/locales/pt/admin.menu-locale.json +11 -0
- package/frontend/menu-screen/locales/en/admin.menu-screen.json +11 -0
- package/frontend/menu-screen/locales/pt/admin.menu-screen.json +11 -0
- package/frontend/multifactor/components/create-panel.tsx.ejs +55 -0
- package/frontend/multifactor/components/update-panel.tsx.ejs +70 -0
- package/frontend/multifactor/locales/en/admin.multifactor.json +11 -0
- package/frontend/multifactor/locales/pt/admin.multifactor.json +11 -0
- package/frontend/multifactor/react-query/handlers.ts.ejs +28 -0
- package/frontend/multifactor/react-query/requests.ts.ejs +59 -0
- package/frontend/multifactor-locale/locales/en/admin.multifactor-locale.json +11 -0
- package/frontend/multifactor-locale/locales/pt/admin.multifactor-locale.json +11 -0
- package/frontend/screen/components/create-panel.tsx.ejs +55 -0
- package/frontend/screen/components/update-panel.tsx.ejs +67 -0
- package/frontend/screen/locales/en/admin.screen.json +11 -0
- package/frontend/screen/locales/pt/admin.screen.json +11 -0
- package/frontend/screen/react-query/handlers.ts.ejs +28 -0
- package/frontend/screen/react-query/requests.ts.ejs +56 -0
- package/frontend/screen-locale/locales/en/admin.screen-locale.json +11 -0
- package/frontend/screen-locale/locales/pt/admin.screen-locale.json +11 -0
- package/frontend/translation/components/create-panel.tsx.ejs +52 -0
- package/frontend/translation/components/update-panel.tsx.ejs +67 -0
- package/frontend/translation/fields/en.json +1 -0
- package/frontend/translation/fields/pt.json +1 -0
- package/frontend/translation/locales/en/admin.translation.json +11 -0
- package/frontend/translation/locales/pt/admin.translation.json +11 -0
- package/frontend/translation/modules/en.json +1 -0
- package/frontend/translation/modules/pt.json +1 -0
- package/frontend/translation/react-query/handlers.ts.ejs +28 -0
- package/frontend/translation/react-query/requests.ts.ejs +58 -0
- package/frontend/translation-namespace/components/create-panel.tsx.ejs +53 -0
- package/frontend/translation-namespace/components/update-panel.tsx.ejs +70 -0
- package/frontend/translation-namespace/locales/en/admin.translation-namespace.json +11 -0
- package/frontend/translation-namespace/locales/pt/admin.translation-namespace.json +11 -0
- package/frontend/translation-namespace/react-query/handlers.ts.ejs +28 -0
- package/frontend/translation-namespace/react-query/requests.ts.ejs +60 -0
- package/frontend/user/components/create-panel.tsx.ejs +52 -0
- package/frontend/user/components/update-panel.tsx.ejs +64 -0
- package/frontend/user/locales/en/admin.user.json +11 -0
- package/frontend/user/locales/pt/admin.user.json +11 -0
- package/frontend/user/react-query/handlers.ts.ejs +28 -0
- package/frontend/user/react-query/requests.ts.ejs +55 -0
- package/{bkp.hedhog.yaml → hedhog.yaml} +1012 -1012
- package/package.json +6 -6
- package/src/admin.module.ts +37 -37
- package/src/auth/auth.controller.ts +72 -72
- package/src/auth/auth.module.ts +39 -39
- package/src/auth/auth.service.spec.ts +196 -196
- package/src/auth/auth.service.ts +234 -234
- package/src/auth/consts/body.ts +26 -26
- package/src/auth/consts/subject.ts +1 -1
- package/src/auth/dto/forget.dto.ts +6 -6
- package/src/auth/dto/login.dto.ts +15 -15
- package/src/auth/dto/otp.dto.ts +11 -11
- package/src/auth/dto/reset.dto.ts +14 -14
- package/src/auth/enums/multifactor-type.enum.ts +4 -4
- package/src/auth/guards/auth.guard.ts +50 -50
- package/src/auth/types/user.type.ts +8 -8
- package/src/dto/delete.dto.ts +8 -8
- package/src/dto/update-ids.dto.ts +9 -9
- package/src/index.ts +20 -20
- package/src/menu/dto/create.dto.ts +25 -25
- package/src/menu/dto/order.dto.ts +8 -8
- package/src/menu/dto/update.dto.ts +19 -19
- package/src/menu/menu.controller.ts +105 -105
- package/src/menu/menu.module.ts +18 -18
- package/src/menu/menu.service.spec.ts +247 -247
- package/src/menu/menu.service.ts +263 -263
- package/src/role/dto/create.dto.ts +7 -7
- package/src/role/dto/update.dto.ts +4 -4
- package/src/role/guards/role.guard.ts +123 -123
- package/src/role/role.controller.ts +126 -126
- package/src/role/role.module.ts +28 -28
- package/src/role/role.service.spec.ts +417 -417
- package/src/role/role.service.ts +289 -289
- package/src/route/dto/create.dto.ts +13 -13
- package/src/route/dto/update.dto.ts +15 -15
- package/src/route/route.controller.ts +91 -91
- package/src/route/route.module.ts +18 -18
- package/src/route/route.service.spec.ts +300 -300
- package/src/route/route.service.ts +164 -164
- package/src/screen/dto/create.dto.ts +11 -11
- package/src/screen/dto/update.dto.ts +19 -19
- package/src/screen/screen.controller.ts +93 -93
- package/src/screen/screen.module.ts +18 -18
- package/src/screen/screen.service.spec.ts +298 -298
- package/src/screen/screen.service.ts +179 -179
- package/src/types/http-method.ts +8 -8
- package/src/user/constants/user.constants.ts +1 -1
- package/src/user/dto/create.dto.ts +24 -24
- package/src/user/dto/update.dto.ts +41 -41
- package/src/user/user.controller.ts +75 -75
- package/src/user/user.module.ts +18 -18
- package/src/user/user.service.spec.ts +294 -294
- package/src/user/user.service.ts +129 -129
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CanActivate,
|
|
3
|
-
ExecutionContext,
|
|
4
|
-
Injectable,
|
|
5
|
-
UnauthorizedException,
|
|
6
|
-
} from '@nestjs/common';
|
|
7
|
-
import { Reflector } from '@nestjs/core';
|
|
8
|
-
import { Request } from 'express';
|
|
9
|
-
import { AuthService } from '../auth.service';
|
|
10
|
-
import { IS_PUBLIC_KEY } from '@hedhog/core';
|
|
11
|
-
|
|
12
|
-
@Injectable()
|
|
13
|
-
export class AuthGuard implements CanActivate {
|
|
14
|
-
constructor(
|
|
15
|
-
private auth: AuthService,
|
|
16
|
-
private reflector: Reflector,
|
|
17
|
-
) {}
|
|
18
|
-
|
|
19
|
-
async canActivate(context: ExecutionContext): Promise<boolean> {
|
|
20
|
-
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
|
|
21
|
-
context.getHandler(),
|
|
22
|
-
context.getClass(),
|
|
23
|
-
]);
|
|
24
|
-
|
|
25
|
-
if (isPublic) {
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const request = context.switchToHttp().getRequest();
|
|
30
|
-
const token = this.extractTokenFromHeader(request);
|
|
31
|
-
|
|
32
|
-
if (!token) {
|
|
33
|
-
throw new UnauthorizedException();
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
const payload = await this.auth.verifyToken(token);
|
|
37
|
-
|
|
38
|
-
request['auth'] = payload;
|
|
39
|
-
} catch (error) {
|
|
40
|
-
throw new UnauthorizedException(error);
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private extractTokenFromHeader(request: Request): string | undefined {
|
|
46
|
-
const [type, token] = request.headers.authorization?.split(' ') ?? [];
|
|
47
|
-
|
|
48
|
-
return type === 'Bearer' ? token : undefined;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
CanActivate,
|
|
3
|
+
ExecutionContext,
|
|
4
|
+
Injectable,
|
|
5
|
+
UnauthorizedException,
|
|
6
|
+
} from '@nestjs/common';
|
|
7
|
+
import { Reflector } from '@nestjs/core';
|
|
8
|
+
import { Request } from 'express';
|
|
9
|
+
import { AuthService } from '../auth.service';
|
|
10
|
+
import { IS_PUBLIC_KEY } from '@hedhog/core';
|
|
11
|
+
|
|
12
|
+
@Injectable()
|
|
13
|
+
export class AuthGuard implements CanActivate {
|
|
14
|
+
constructor(
|
|
15
|
+
private auth: AuthService,
|
|
16
|
+
private reflector: Reflector,
|
|
17
|
+
) {}
|
|
18
|
+
|
|
19
|
+
async canActivate(context: ExecutionContext): Promise<boolean> {
|
|
20
|
+
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
|
|
21
|
+
context.getHandler(),
|
|
22
|
+
context.getClass(),
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
if (isPublic) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const request = context.switchToHttp().getRequest();
|
|
30
|
+
const token = this.extractTokenFromHeader(request);
|
|
31
|
+
|
|
32
|
+
if (!token) {
|
|
33
|
+
throw new UnauthorizedException();
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const payload = await this.auth.verifyToken(token);
|
|
37
|
+
|
|
38
|
+
request['auth'] = payload;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
throw new UnauthorizedException(error);
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private extractTokenFromHeader(request: Request): string | undefined {
|
|
46
|
+
const [type, token] = request.headers.authorization?.split(' ') ?? [];
|
|
47
|
+
|
|
48
|
+
return type === 'Bearer' ? token : undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export type User = {
|
|
2
|
-
id: number;
|
|
3
|
-
name: string;
|
|
4
|
-
email: string;
|
|
5
|
-
password: string;
|
|
6
|
-
created_at: string;
|
|
7
|
-
updated_at: string;
|
|
8
|
-
};
|
|
1
|
+
export type User = {
|
|
2
|
+
id: number;
|
|
3
|
+
name: string;
|
|
4
|
+
email: string;
|
|
5
|
+
password: string;
|
|
6
|
+
created_at: string;
|
|
7
|
+
updated_at: string;
|
|
8
|
+
};
|
package/src/dto/delete.dto.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ArrayMinSize, IsArray, IsInt } from 'class-validator';
|
|
2
|
-
|
|
3
|
-
export class DeleteDTO {
|
|
4
|
-
@IsArray()
|
|
5
|
-
@ArrayMinSize(1)
|
|
6
|
-
@IsInt({ each: true })
|
|
7
|
-
ids: number[];
|
|
8
|
-
}
|
|
1
|
+
import { ArrayMinSize, IsArray, IsInt } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export class DeleteDTO {
|
|
4
|
+
@IsArray()
|
|
5
|
+
@ArrayMinSize(1)
|
|
6
|
+
@IsInt({ each: true })
|
|
7
|
+
ids: number[];
|
|
8
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { IsArray, IsInt } from 'class-validator';
|
|
2
|
-
|
|
3
|
-
export class UpdateIdsDTO {
|
|
4
|
-
@IsInt({
|
|
5
|
-
each: true,
|
|
6
|
-
})
|
|
7
|
-
@IsArray()
|
|
8
|
-
ids: number[];
|
|
9
|
-
}
|
|
1
|
+
import { IsArray, IsInt } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export class UpdateIdsDTO {
|
|
4
|
+
@IsInt({
|
|
5
|
+
each: true,
|
|
6
|
+
})
|
|
7
|
+
@IsArray()
|
|
8
|
+
ids: number[];
|
|
9
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
// Admin Module
|
|
2
|
-
export * from './admin.module';
|
|
3
|
-
|
|
4
|
-
// Auth Module
|
|
5
|
-
export * from './auth/auth.service';
|
|
6
|
-
export * from './auth/guards/auth.guard';
|
|
7
|
-
|
|
8
|
-
// Menu Module
|
|
9
|
-
export * from './menu/menu.service';
|
|
10
|
-
|
|
11
|
-
// Permission Module
|
|
12
|
-
export * from './role/guards/role.guard';
|
|
13
|
-
export * from './role/role.service';
|
|
14
|
-
|
|
15
|
-
// Screen Module
|
|
16
|
-
export * from './screen/screen.service';
|
|
17
|
-
|
|
18
|
-
// User Module
|
|
19
|
-
export * from './user/constants/user.constants';
|
|
20
|
-
export * from './user/user.service';
|
|
1
|
+
// Admin Module
|
|
2
|
+
export * from './admin.module';
|
|
3
|
+
|
|
4
|
+
// Auth Module
|
|
5
|
+
export * from './auth/auth.service';
|
|
6
|
+
export * from './auth/guards/auth.guard';
|
|
7
|
+
|
|
8
|
+
// Menu Module
|
|
9
|
+
export * from './menu/menu.service';
|
|
10
|
+
|
|
11
|
+
// Permission Module
|
|
12
|
+
export * from './role/guards/role.guard';
|
|
13
|
+
export * from './role/role.service';
|
|
14
|
+
|
|
15
|
+
// Screen Module
|
|
16
|
+
export * from './screen/screen.service';
|
|
17
|
+
|
|
18
|
+
// User Module
|
|
19
|
+
export * from './user/constants/user.constants';
|
|
20
|
+
export * from './user/user.service';
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { IsInt, IsNotEmpty, IsOptional, IsString, Min } from 'class-validator';
|
|
2
|
-
|
|
3
|
-
export class CreateDTO {
|
|
4
|
-
@IsString({ message: 'O slug deve ser uma string' })
|
|
5
|
-
@IsNotEmpty({ message: 'O slug é obrigatório.' })
|
|
6
|
-
slug: string;
|
|
7
|
-
|
|
8
|
-
@IsString({ message: 'A url deve ser uma string' })
|
|
9
|
-
@IsNotEmpty({ message: 'A url é obrigatório.' })
|
|
10
|
-
url: string;
|
|
11
|
-
|
|
12
|
-
@IsInt({ message: 'Order deve ser um número.' })
|
|
13
|
-
@Min(1)
|
|
14
|
-
@IsOptional()
|
|
15
|
-
order?: number;
|
|
16
|
-
|
|
17
|
-
@IsString({ message: 'O ícone deve ser uma string' })
|
|
18
|
-
@IsOptional()
|
|
19
|
-
icon?: string;
|
|
20
|
-
|
|
21
|
-
@IsInt({ message: 'MenuID deve ser um número.' })
|
|
22
|
-
@Min(1)
|
|
23
|
-
@IsOptional()
|
|
24
|
-
menuId?: number;
|
|
25
|
-
}
|
|
1
|
+
import { IsInt, IsNotEmpty, IsOptional, IsString, Min } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export class CreateDTO {
|
|
4
|
+
@IsString({ message: 'O slug deve ser uma string' })
|
|
5
|
+
@IsNotEmpty({ message: 'O slug é obrigatório.' })
|
|
6
|
+
slug: string;
|
|
7
|
+
|
|
8
|
+
@IsString({ message: 'A url deve ser uma string' })
|
|
9
|
+
@IsNotEmpty({ message: 'A url é obrigatório.' })
|
|
10
|
+
url: string;
|
|
11
|
+
|
|
12
|
+
@IsInt({ message: 'Order deve ser um número.' })
|
|
13
|
+
@Min(1)
|
|
14
|
+
@IsOptional()
|
|
15
|
+
order?: number;
|
|
16
|
+
|
|
17
|
+
@IsString({ message: 'O ícone deve ser uma string' })
|
|
18
|
+
@IsOptional()
|
|
19
|
+
icon?: string;
|
|
20
|
+
|
|
21
|
+
@IsInt({ message: 'MenuID deve ser um número.' })
|
|
22
|
+
@Min(1)
|
|
23
|
+
@IsOptional()
|
|
24
|
+
menuId?: number;
|
|
25
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ArrayMinSize, IsArray, IsInt } from 'class-validator';
|
|
2
|
-
|
|
3
|
-
export class OrderDTO {
|
|
4
|
-
@IsArray()
|
|
5
|
-
@ArrayMinSize(1)
|
|
6
|
-
@IsInt({ each: true })
|
|
7
|
-
ids: number[];
|
|
8
|
-
}
|
|
1
|
+
import { ArrayMinSize, IsArray, IsInt } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export class OrderDTO {
|
|
4
|
+
@IsArray()
|
|
5
|
+
@ArrayMinSize(1)
|
|
6
|
+
@IsInt({ each: true })
|
|
7
|
+
ids: number[];
|
|
8
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { IsInt, IsOptional, IsString } from 'class-validator';
|
|
2
|
-
|
|
3
|
-
export class UpdateDTO {
|
|
4
|
-
@IsString({ message: 'O nome deve ser uma string' })
|
|
5
|
-
@IsOptional()
|
|
6
|
-
name?: string;
|
|
7
|
-
|
|
8
|
-
@IsString({ message: 'A url deve ser uma string' })
|
|
9
|
-
@IsOptional()
|
|
10
|
-
url?: string;
|
|
11
|
-
|
|
12
|
-
@IsInt({ message: 'Order deve ser um número.' })
|
|
13
|
-
@IsOptional()
|
|
14
|
-
order?: number;
|
|
15
|
-
|
|
16
|
-
@IsString({ message: 'O ícone deve ser uma string' })
|
|
17
|
-
@IsOptional()
|
|
18
|
-
icon?: string;
|
|
19
|
-
}
|
|
1
|
+
import { IsInt, IsOptional, IsString } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export class UpdateDTO {
|
|
4
|
+
@IsString({ message: 'O nome deve ser uma string' })
|
|
5
|
+
@IsOptional()
|
|
6
|
+
name?: string;
|
|
7
|
+
|
|
8
|
+
@IsString({ message: 'A url deve ser uma string' })
|
|
9
|
+
@IsOptional()
|
|
10
|
+
url?: string;
|
|
11
|
+
|
|
12
|
+
@IsInt({ message: 'Order deve ser um número.' })
|
|
13
|
+
@IsOptional()
|
|
14
|
+
order?: number;
|
|
15
|
+
|
|
16
|
+
@IsString({ message: 'O ícone deve ser uma string' })
|
|
17
|
+
@IsOptional()
|
|
18
|
+
icon?: string;
|
|
19
|
+
}
|
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
import { Pagination } from '@hedhog/pagination';
|
|
2
|
-
import {
|
|
3
|
-
Body,
|
|
4
|
-
Controller,
|
|
5
|
-
Delete,
|
|
6
|
-
Get,
|
|
7
|
-
Inject,
|
|
8
|
-
Param,
|
|
9
|
-
ParseIntPipe,
|
|
10
|
-
Patch,
|
|
11
|
-
Post,
|
|
12
|
-
forwardRef,
|
|
13
|
-
} from '@nestjs/common';
|
|
14
|
-
import { DeleteDTO } from '../dto/delete.dto';
|
|
15
|
-
import { UpdateIdsDTO } from '../dto/update-ids.dto';
|
|
16
|
-
import { Locale } from '@hedhog/locale';
|
|
17
|
-
import { Role, User } from '@hedhog/core';
|
|
18
|
-
import { CreateDTO } from './dto/create.dto';
|
|
19
|
-
import { OrderDTO } from './dto/order.dto';
|
|
20
|
-
import { UpdateDTO } from './dto/update.dto';
|
|
21
|
-
import { MenuService } from './menu.service';
|
|
22
|
-
|
|
23
|
-
@Role()
|
|
24
|
-
@Controller('menu')
|
|
25
|
-
export class MenuController {
|
|
26
|
-
constructor(
|
|
27
|
-
@Inject(forwardRef(() => MenuService))
|
|
28
|
-
private readonly menuService: MenuService,
|
|
29
|
-
) {}
|
|
30
|
-
|
|
31
|
-
@Get('system')
|
|
32
|
-
async getSystemMenu(@User() { id }, @Locale() locale) {
|
|
33
|
-
return this.menuService.getSystemMenu(locale, id);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@Get()
|
|
37
|
-
async list(@Pagination() paginationParams, @Locale() locale) {
|
|
38
|
-
return this.menuService.list(locale, paginationParams);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@Get(':menuId/role')
|
|
42
|
-
async listRoles(
|
|
43
|
-
@Param('menuId', ParseIntPipe) menuId: number,
|
|
44
|
-
@Pagination() paginationParams,
|
|
45
|
-
@Locale() locale,
|
|
46
|
-
) {
|
|
47
|
-
return this.menuService.listRoles(locale, menuId, paginationParams);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@Get(':menuId/screen')
|
|
51
|
-
async listScreens(
|
|
52
|
-
@Param('menuId', ParseIntPipe) menuId: number,
|
|
53
|
-
@Pagination() paginationParams,
|
|
54
|
-
@Locale() locale,
|
|
55
|
-
) {
|
|
56
|
-
return this.menuService.listScreens(locale, menuId, paginationParams);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@Patch(':menuId/role')
|
|
60
|
-
async updateRoles(
|
|
61
|
-
@Param('menuId', ParseIntPipe) menuId: number,
|
|
62
|
-
@Body() data: UpdateIdsDTO,
|
|
63
|
-
) {
|
|
64
|
-
return this.menuService.updateRoles(menuId, data);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@Patch(':menuId/screen')
|
|
68
|
-
async updateScreens(
|
|
69
|
-
@Param('menuId', ParseIntPipe) menuId: number,
|
|
70
|
-
@Body() data: UpdateIdsDTO,
|
|
71
|
-
) {
|
|
72
|
-
return this.menuService.updateScreens(menuId, data);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@Get(':menuId')
|
|
76
|
-
async show(@Param('menuId', ParseIntPipe) menuId: number) {
|
|
77
|
-
return this.menuService.get(menuId);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
@Post()
|
|
81
|
-
async create(@Body() data: CreateDTO) {
|
|
82
|
-
return this.menuService.create(data);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
@Patch(':menuId')
|
|
86
|
-
async update(
|
|
87
|
-
@Param('menuId', ParseIntPipe) menuId: number,
|
|
88
|
-
@Body() data: UpdateDTO,
|
|
89
|
-
) {
|
|
90
|
-
return this.menuService.update({
|
|
91
|
-
id: menuId,
|
|
92
|
-
data,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@Delete()
|
|
97
|
-
async delete(@Body() data: DeleteDTO) {
|
|
98
|
-
return this.menuService.delete(data);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
@Patch('order')
|
|
102
|
-
async updateOrder(@Body() data: OrderDTO): Promise<void> {
|
|
103
|
-
return this.menuService.updateOrder(data);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
1
|
+
import { Pagination } from '@hedhog/pagination';
|
|
2
|
+
import {
|
|
3
|
+
Body,
|
|
4
|
+
Controller,
|
|
5
|
+
Delete,
|
|
6
|
+
Get,
|
|
7
|
+
Inject,
|
|
8
|
+
Param,
|
|
9
|
+
ParseIntPipe,
|
|
10
|
+
Patch,
|
|
11
|
+
Post,
|
|
12
|
+
forwardRef,
|
|
13
|
+
} from '@nestjs/common';
|
|
14
|
+
import { DeleteDTO } from '../dto/delete.dto';
|
|
15
|
+
import { UpdateIdsDTO } from '../dto/update-ids.dto';
|
|
16
|
+
import { Locale } from '@hedhog/locale';
|
|
17
|
+
import { Role, User } from '@hedhog/core';
|
|
18
|
+
import { CreateDTO } from './dto/create.dto';
|
|
19
|
+
import { OrderDTO } from './dto/order.dto';
|
|
20
|
+
import { UpdateDTO } from './dto/update.dto';
|
|
21
|
+
import { MenuService } from './menu.service';
|
|
22
|
+
|
|
23
|
+
@Role()
|
|
24
|
+
@Controller('menu')
|
|
25
|
+
export class MenuController {
|
|
26
|
+
constructor(
|
|
27
|
+
@Inject(forwardRef(() => MenuService))
|
|
28
|
+
private readonly menuService: MenuService,
|
|
29
|
+
) {}
|
|
30
|
+
|
|
31
|
+
@Get('system')
|
|
32
|
+
async getSystemMenu(@User() { id }, @Locale() locale) {
|
|
33
|
+
return this.menuService.getSystemMenu(locale, id);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Get()
|
|
37
|
+
async list(@Pagination() paginationParams, @Locale() locale) {
|
|
38
|
+
return this.menuService.list(locale, paginationParams);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Get(':menuId/role')
|
|
42
|
+
async listRoles(
|
|
43
|
+
@Param('menuId', ParseIntPipe) menuId: number,
|
|
44
|
+
@Pagination() paginationParams,
|
|
45
|
+
@Locale() locale,
|
|
46
|
+
) {
|
|
47
|
+
return this.menuService.listRoles(locale, menuId, paginationParams);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@Get(':menuId/screen')
|
|
51
|
+
async listScreens(
|
|
52
|
+
@Param('menuId', ParseIntPipe) menuId: number,
|
|
53
|
+
@Pagination() paginationParams,
|
|
54
|
+
@Locale() locale,
|
|
55
|
+
) {
|
|
56
|
+
return this.menuService.listScreens(locale, menuId, paginationParams);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@Patch(':menuId/role')
|
|
60
|
+
async updateRoles(
|
|
61
|
+
@Param('menuId', ParseIntPipe) menuId: number,
|
|
62
|
+
@Body() data: UpdateIdsDTO,
|
|
63
|
+
) {
|
|
64
|
+
return this.menuService.updateRoles(menuId, data);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@Patch(':menuId/screen')
|
|
68
|
+
async updateScreens(
|
|
69
|
+
@Param('menuId', ParseIntPipe) menuId: number,
|
|
70
|
+
@Body() data: UpdateIdsDTO,
|
|
71
|
+
) {
|
|
72
|
+
return this.menuService.updateScreens(menuId, data);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@Get(':menuId')
|
|
76
|
+
async show(@Param('menuId', ParseIntPipe) menuId: number) {
|
|
77
|
+
return this.menuService.get(menuId);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Post()
|
|
81
|
+
async create(@Body() data: CreateDTO) {
|
|
82
|
+
return this.menuService.create(data);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@Patch(':menuId')
|
|
86
|
+
async update(
|
|
87
|
+
@Param('menuId', ParseIntPipe) menuId: number,
|
|
88
|
+
@Body() data: UpdateDTO,
|
|
89
|
+
) {
|
|
90
|
+
return this.menuService.update({
|
|
91
|
+
id: menuId,
|
|
92
|
+
data,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@Delete()
|
|
97
|
+
async delete(@Body() data: DeleteDTO) {
|
|
98
|
+
return this.menuService.delete(data);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@Patch('order')
|
|
102
|
+
async updateOrder(@Body() data: OrderDTO): Promise<void> {
|
|
103
|
+
return this.menuService.updateOrder(data);
|
|
104
|
+
}
|
|
105
|
+
}
|
package/src/menu/menu.module.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { AuthModule } from '../auth/auth.module';
|
|
2
|
-
import { PaginationModule } from '@hedhog/pagination';
|
|
3
|
-
import { PrismaModule } from '@hedhog/prisma';
|
|
4
|
-
import { Module, forwardRef } from '@nestjs/common';
|
|
5
|
-
import { MenuController } from './menu.controller';
|
|
6
|
-
import { MenuService } from './menu.service';
|
|
7
|
-
|
|
8
|
-
@Module({
|
|
9
|
-
providers: [MenuService],
|
|
10
|
-
exports: [MenuService],
|
|
11
|
-
controllers: [MenuController],
|
|
12
|
-
imports: [
|
|
13
|
-
forwardRef(() => AuthModule),
|
|
14
|
-
forwardRef(() => PrismaModule),
|
|
15
|
-
forwardRef(() => PaginationModule),
|
|
16
|
-
],
|
|
17
|
-
})
|
|
18
|
-
export class MenuModule {}
|
|
1
|
+
import { AuthModule } from '../auth/auth.module';
|
|
2
|
+
import { PaginationModule } from '@hedhog/pagination';
|
|
3
|
+
import { PrismaModule } from '@hedhog/prisma';
|
|
4
|
+
import { Module, forwardRef } from '@nestjs/common';
|
|
5
|
+
import { MenuController } from './menu.controller';
|
|
6
|
+
import { MenuService } from './menu.service';
|
|
7
|
+
|
|
8
|
+
@Module({
|
|
9
|
+
providers: [MenuService],
|
|
10
|
+
exports: [MenuService],
|
|
11
|
+
controllers: [MenuController],
|
|
12
|
+
imports: [
|
|
13
|
+
forwardRef(() => AuthModule),
|
|
14
|
+
forwardRef(() => PrismaModule),
|
|
15
|
+
forwardRef(() => PaginationModule),
|
|
16
|
+
],
|
|
17
|
+
})
|
|
18
|
+
export class MenuModule {}
|