@hed-hog/core 0.0.170 → 0.0.171
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/dashboard/dashboard-component/dashboard-component.controller.d.ts +70 -1
- package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts.map +1 -1
- package/dist/dashboard/dashboard-component/dashboard-component.controller.js +13 -3
- package/dist/dashboard/dashboard-component/dashboard-component.controller.js.map +1 -1
- package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts +70 -1
- package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts.map +1 -1
- package/dist/dashboard/dashboard-component/dashboard-component.service.js +33 -4
- package/dist/dashboard/dashboard-component/dashboard-component.service.js.map +1 -1
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.controller.d.ts +122 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.controller.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.controller.js +83 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.controller.js.map +1 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.module.d.ts +3 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.module.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.module.js +26 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.module.js.map +1 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.service.d.ts +125 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.service.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.service.js +143 -0
- package/dist/dashboard/dashboard-component-role/dashboard-component-role.service.js.map +1 -0
- package/dist/dashboard/dashboard-component-role/dto/create.dto.d.ts +5 -0
- package/dist/dashboard/dashboard-component-role/dto/create.dto.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component-role/dto/create.dto.js +25 -0
- package/dist/dashboard/dashboard-component-role/dto/create.dto.js.map +1 -0
- package/dist/dashboard/dashboard-component-role/dto/index.d.ts +2 -0
- package/dist/dashboard/dashboard-component-role/dto/index.d.ts.map +1 -0
- package/dist/dashboard/dashboard-component-role/dto/index.js +18 -0
- package/dist/dashboard/dashboard-component-role/dto/index.js.map +1 -0
- package/dist/dashboard/dashboard.module.d.ts.map +1 -1
- package/dist/dashboard/dashboard.module.js +2 -0
- package/dist/dashboard/dashboard.module.js.map +1 -1
- package/hedhog/data/route.yaml +30 -0
- package/package.json +3 -3
- package/src/dashboard/dashboard-component/dashboard-component.controller.ts +7 -2
- package/src/dashboard/dashboard-component/dashboard-component.service.ts +44 -4
- package/src/dashboard/dashboard-component-role/dashboard-component-role.controller.ts +57 -0
- package/src/dashboard/dashboard-component-role/dashboard-component-role.module.ts +13 -0
- package/src/dashboard/dashboard-component-role/dashboard-component-role.service.ts +170 -0
- package/src/dashboard/dashboard-component-role/dto/create.dto.ts +9 -0
- package/src/dashboard/dashboard-component-role/dto/index.ts +1 -0
- package/src/dashboard/dashboard.module.ts +2 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { getLocaleText } from '@hed-hog/api-locale';
|
|
2
|
+
import { PaginationService } from '@hed-hog/api-pagination';
|
|
3
|
+
import { PrismaService } from '@hed-hog/api-prisma';
|
|
4
|
+
import {
|
|
5
|
+
forwardRef,
|
|
6
|
+
Inject,
|
|
7
|
+
Injectable,
|
|
8
|
+
NotFoundException,
|
|
9
|
+
} from '@nestjs/common';
|
|
10
|
+
import { CreateDashboardComponentRoleDTO } from './dto';
|
|
11
|
+
|
|
12
|
+
@Injectable()
|
|
13
|
+
export class DashboardComponentRoleService {
|
|
14
|
+
constructor(
|
|
15
|
+
@Inject(forwardRef(() => PrismaService))
|
|
16
|
+
private readonly prismaService: PrismaService,
|
|
17
|
+
@Inject(forwardRef(() => PaginationService))
|
|
18
|
+
private readonly paginationService: PaginationService,
|
|
19
|
+
) {}
|
|
20
|
+
|
|
21
|
+
async getAll(paginationParams, locale: string) {
|
|
22
|
+
return this.paginationService.paginate(
|
|
23
|
+
this.prismaService.dashboard_component_role,
|
|
24
|
+
paginationParams,
|
|
25
|
+
{
|
|
26
|
+
include: {
|
|
27
|
+
dashboard_component: {
|
|
28
|
+
include: {
|
|
29
|
+
dashboard_component_locale: {
|
|
30
|
+
include: {
|
|
31
|
+
locale: true,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
role: {
|
|
37
|
+
include: {
|
|
38
|
+
role_locale: {
|
|
39
|
+
include: {
|
|
40
|
+
locale: true,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
orderBy: {
|
|
47
|
+
id: 'desc',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
'dashboardComponentRole',
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async getAllByComponent(componentId: number, locale: string) {
|
|
55
|
+
const relations = await this.prismaService.dashboard_component_role.findMany({
|
|
56
|
+
where: { component_id: componentId },
|
|
57
|
+
include: {
|
|
58
|
+
role: {
|
|
59
|
+
include: {
|
|
60
|
+
role_locale: {
|
|
61
|
+
include: {
|
|
62
|
+
locale: true,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return relations;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async create(data: CreateDashboardComponentRoleDTO, locale: string) {
|
|
74
|
+
// Verificar se a relação já existe
|
|
75
|
+
const existing = await this.prismaService.dashboard_component_role.findFirst({
|
|
76
|
+
where: {
|
|
77
|
+
component_id: data.component_id,
|
|
78
|
+
role_id: data.role_id,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
if (existing) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
getLocaleText(
|
|
85
|
+
'dashboardComponentRoleAlreadyExists',
|
|
86
|
+
locale,
|
|
87
|
+
'Dashboard component role already exists',
|
|
88
|
+
),
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return this.prismaService.dashboard_component_role.create({
|
|
93
|
+
data: {
|
|
94
|
+
component_id: data.component_id,
|
|
95
|
+
role_id: data.role_id,
|
|
96
|
+
},
|
|
97
|
+
include: {
|
|
98
|
+
dashboard_component: {
|
|
99
|
+
include: {
|
|
100
|
+
dashboard_component_locale: {
|
|
101
|
+
include: {
|
|
102
|
+
locale: true,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
role: {
|
|
108
|
+
include: {
|
|
109
|
+
role_locale: {
|
|
110
|
+
include: {
|
|
111
|
+
locale: true,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async delete(id: number, locale: string) {
|
|
121
|
+
const relation = await this.prismaService.dashboard_component_role.findUnique({
|
|
122
|
+
where: { id },
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
if (!relation) {
|
|
126
|
+
throw new NotFoundException(
|
|
127
|
+
getLocaleText(
|
|
128
|
+
'dashboardComponentRoleNotFound',
|
|
129
|
+
locale,
|
|
130
|
+
'Dashboard component role not found',
|
|
131
|
+
),
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
await this.prismaService.dashboard_component_role.delete({
|
|
136
|
+
where: { id },
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return { success: true };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async deleteByComponentAndRole(
|
|
143
|
+
componentId: number,
|
|
144
|
+
roleId: number,
|
|
145
|
+
locale: string,
|
|
146
|
+
) {
|
|
147
|
+
const relation = await this.prismaService.dashboard_component_role.findFirst({
|
|
148
|
+
where: {
|
|
149
|
+
component_id: componentId,
|
|
150
|
+
role_id: roleId,
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
if (!relation) {
|
|
155
|
+
throw new NotFoundException(
|
|
156
|
+
getLocaleText(
|
|
157
|
+
'dashboardComponentRoleNotFound',
|
|
158
|
+
locale,
|
|
159
|
+
'Dashboard component role not found',
|
|
160
|
+
),
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
await this.prismaService.dashboard_component_role.delete({
|
|
165
|
+
where: { id: relation.id },
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
return { success: true };
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './create.dto';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LocaleModule } from '@hed-hog/api-locale';
|
|
2
2
|
import { PrismaModule } from '@hed-hog/api-prisma';
|
|
3
3
|
import { forwardRef, Module } from '@nestjs/common';
|
|
4
|
+
import { DashboardComponentRoleModule } from './dashboard-component-role/dashboard-component-role.module';
|
|
4
5
|
import { DashboardComponentModule } from './dashboard-component/dashboard-component.module';
|
|
5
6
|
import { DashboardCoreModule } from './dashboard-core/dashboard-core.module';
|
|
6
7
|
import { DashboardItemModule } from './dashboard-item/dashboard-item.module';
|
|
@@ -13,6 +14,7 @@ import { DashboardCrudModule } from './dashboard/dashboard.module';
|
|
|
13
14
|
forwardRef(() => PrismaModule),
|
|
14
15
|
forwardRef(() => DashboardCrudModule),
|
|
15
16
|
forwardRef(() => DashboardComponentModule),
|
|
17
|
+
forwardRef(() => DashboardComponentRoleModule),
|
|
16
18
|
forwardRef(() => DashboardItemModule),
|
|
17
19
|
forwardRef(() => DashboardUserModule),
|
|
18
20
|
forwardRef(() => DashboardCoreModule),
|