@hedhog/admin 0.0.36 → 0.0.38
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/admin.module.d.ts.map +1 -1
- package/dist/admin.module.js +2 -0
- package/dist/admin.module.js.map +1 -1
- package/dist/locale/dto/create.dto.d.ts +7 -0
- package/dist/locale/dto/create.dto.d.ts.map +1 -0
- package/dist/locale/dto/create.dto.js +33 -0
- package/dist/locale/dto/create.dto.js.map +1 -0
- package/dist/locale/dto/delete.dto.d.ts +4 -0
- package/dist/locale/dto/delete.dto.d.ts.map +1 -0
- package/dist/locale/dto/delete.dto.js +23 -0
- package/dist/locale/dto/delete.dto.js.map +1 -0
- package/dist/locale/dto/update.dto.d.ts +7 -0
- package/dist/locale/dto/update.dto.d.ts.map +1 -0
- package/dist/locale/dto/update.dto.js +37 -0
- package/dist/locale/dto/update.dto.js.map +1 -0
- package/dist/locale/index.d.ts +5 -0
- package/dist/locale/index.d.ts.map +1 -0
- package/dist/locale/index.js +21 -0
- package/dist/locale/index.js.map +1 -0
- package/dist/locale/locale.controller.d.ts +16 -0
- package/dist/locale/locale.controller.d.ts.map +1 -0
- package/dist/locale/locale.controller.js +110 -0
- package/dist/locale/locale.controller.js.map +1 -0
- package/dist/locale/locale.decorator.d.ts +2 -0
- package/dist/locale/locale.decorator.d.ts.map +1 -0
- package/dist/locale/locale.decorator.js +9 -0
- package/dist/locale/locale.decorator.js.map +1 -0
- package/dist/locale/locale.middleware.d.ts +10 -0
- package/dist/locale/locale.middleware.d.ts.map +1 -0
- package/dist/locale/locale.middleware.js +45 -0
- package/dist/locale/locale.middleware.js.map +1 -0
- package/dist/locale/locale.module.d.ts +5 -0
- package/dist/locale/locale.module.d.ts.map +1 -0
- package/dist/locale/locale.module.js +35 -0
- package/dist/locale/locale.module.js.map +1 -0
- package/dist/locale/locale.service.d.ts +26 -0
- package/dist/locale/locale.service.d.ts.map +1 -0
- package/dist/locale/locale.service.js +166 -0
- package/dist/locale/locale.service.js.map +1 -0
- package/dist/menu/menu.controller.js +1 -1
- package/dist/menu/menu.controller.js.map +1 -1
- package/dist/role/role.controller.d.ts.map +1 -1
- package/dist/role/role.controller.js +1 -1
- package/dist/role/role.controller.js.map +1 -1
- package/dist/route/route.controller.js +1 -1
- package/dist/route/route.controller.js.map +1 -1
- package/dist/screen/screen.controller.js +1 -1
- package/dist/screen/screen.controller.js.map +1 -1
- package/package.json +1 -3
- package/src/migrations/migrate-01.ts +270 -121
- package/src/migrations/migrate-02.ts +137 -236
- package/src/migrations/migrate-03.ts +98 -192
- package/src/migrations/migrate-04.ts +167 -197
- package/src/migrations/migrate-05.ts +185 -42
- package/src/migrations/migrate-06.ts +245 -33
- package/src/migrations/migrate-07.ts +87 -21
- package/src/migrations/migrate-08.ts +8 -8
- package/src/migrations/migrate-09.ts +13 -14
- package/src/migrations/migrate-10.ts +8 -8
- package/src/migrations/migrate-11.ts +46 -17
- package/src/migrations/migrate-12.ts +46 -71
- package/src/migrations/migrate-13.ts +15 -9
- package/src/migrations/migrate-14.ts +55 -33
- package/src/migrations/migrate-15.ts +9 -16
- package/src/migrations/migrate-16.ts +37 -17
- package/src/migrations/migrate-17.ts +20 -169
- package/src/migrations/migrate-18.ts +30 -191
- package/src/migrations/migrate-19.ts +176 -0
- package/src/migrations/migrate-20.ts +198 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
import { timestampColumn } from '@hedhog/utils';
|
1
|
+
import { idColumn, timestampColumn } from '@hedhog/utils';
|
2
2
|
import {
|
3
3
|
MigrationInterface,
|
4
4
|
QueryRunner,
|
@@ -10,45 +10,111 @@ export class Migrate implements MigrationInterface {
|
|
10
10
|
async up(queryRunner: QueryRunner) {
|
11
11
|
await queryRunner.createTable(
|
12
12
|
new Table({
|
13
|
-
name: '
|
13
|
+
name: 'roles',
|
14
|
+
columns: [idColumn(), timestampColumn(), timestampColumn('updated_at')],
|
15
|
+
}),
|
16
|
+
);
|
17
|
+
|
18
|
+
await queryRunner.createTable(
|
19
|
+
new Table({
|
20
|
+
name: 'role_translations',
|
14
21
|
columns: [
|
15
22
|
{
|
16
|
-
name: '
|
23
|
+
name: 'role_id',
|
17
24
|
type: 'int',
|
18
25
|
unsigned: true,
|
19
26
|
isPrimary: true,
|
20
27
|
},
|
21
28
|
{
|
22
|
-
name: '
|
29
|
+
name: 'locale_id',
|
23
30
|
type: 'int',
|
24
31
|
unsigned: true,
|
25
32
|
isPrimary: true,
|
26
33
|
},
|
34
|
+
{
|
35
|
+
name: 'name',
|
36
|
+
type: 'varchar',
|
37
|
+
isNullable: false,
|
38
|
+
},
|
39
|
+
{
|
40
|
+
name: 'description',
|
41
|
+
type: 'varchar',
|
42
|
+
},
|
27
43
|
timestampColumn(),
|
28
44
|
timestampColumn('updated_at'),
|
29
45
|
],
|
46
|
+
foreignKeys: [
|
47
|
+
new TableForeignKey({
|
48
|
+
columnNames: ['role_id'],
|
49
|
+
referencedTableName: 'roles',
|
50
|
+
referencedColumnNames: ['id'],
|
51
|
+
onDelete: 'CASCADE',
|
52
|
+
}),
|
53
|
+
new TableForeignKey({
|
54
|
+
columnNames: ['locale_id'],
|
55
|
+
referencedTableName: 'locales',
|
56
|
+
referencedColumnNames: ['id'],
|
57
|
+
onDelete: 'CASCADE',
|
58
|
+
}),
|
59
|
+
],
|
30
60
|
}),
|
31
61
|
);
|
32
62
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
}
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
48
|
-
]
|
63
|
+
const roles = [
|
64
|
+
{
|
65
|
+
id: 1,
|
66
|
+
name_en: 'Administrator',
|
67
|
+
name_pt: 'Administrador',
|
68
|
+
description_en: 'System administrator',
|
69
|
+
description_pt: 'Administrador do sistema',
|
70
|
+
},
|
71
|
+
{
|
72
|
+
id: 2,
|
73
|
+
name_en: 'Screen Manager',
|
74
|
+
name_pt: 'Gerenciador de telas',
|
75
|
+
description_en: 'Screen manager',
|
76
|
+
description_pt: 'Gerenciador de telas',
|
77
|
+
},
|
78
|
+
];
|
79
|
+
|
80
|
+
for (const role of roles) {
|
81
|
+
await queryRunner.manager
|
82
|
+
.createQueryBuilder()
|
83
|
+
.insert()
|
84
|
+
.into('roles', ['id'])
|
85
|
+
.values({
|
86
|
+
id: role.id,
|
87
|
+
})
|
88
|
+
.execute();
|
89
|
+
|
90
|
+
await queryRunner.manager
|
91
|
+
.createQueryBuilder()
|
92
|
+
.insert()
|
93
|
+
.into('role_translations', [
|
94
|
+
'role_id',
|
95
|
+
'locale_id',
|
96
|
+
'name',
|
97
|
+
'description',
|
98
|
+
])
|
99
|
+
.values([
|
100
|
+
{
|
101
|
+
role_id: role.id,
|
102
|
+
locale_id: 1,
|
103
|
+
name: role.name_en,
|
104
|
+
description: role.description_en,
|
105
|
+
},
|
106
|
+
{
|
107
|
+
role_id: role.id,
|
108
|
+
locale_id: 2,
|
109
|
+
name: role.name_pt,
|
110
|
+
description: role.description_pt,
|
111
|
+
},
|
112
|
+
])
|
113
|
+
.execute();
|
114
|
+
}
|
49
115
|
}
|
50
116
|
|
51
117
|
async down(queryRunner: QueryRunner) {
|
52
|
-
await queryRunner.dropTable('
|
118
|
+
await queryRunner.dropTable('roles');
|
53
119
|
}
|
54
120
|
}
|
@@ -10,7 +10,7 @@ export class Migrate implements MigrationInterface {
|
|
10
10
|
async up(queryRunner: QueryRunner) {
|
11
11
|
await queryRunner.createTable(
|
12
12
|
new Table({
|
13
|
-
name: '
|
13
|
+
name: 'role_menus',
|
14
14
|
columns: [
|
15
15
|
{
|
16
16
|
name: 'role_id',
|
@@ -19,7 +19,7 @@ export class Migrate implements MigrationInterface {
|
|
19
19
|
unsigned: true,
|
20
20
|
},
|
21
21
|
{
|
22
|
-
name: '
|
22
|
+
name: 'menu_id',
|
23
23
|
type: 'int',
|
24
24
|
isPrimary: true,
|
25
25
|
unsigned: true,
|
@@ -30,25 +30,25 @@ export class Migrate implements MigrationInterface {
|
|
30
30
|
}),
|
31
31
|
);
|
32
32
|
|
33
|
-
await queryRunner.createForeignKeys('
|
33
|
+
await queryRunner.createForeignKeys('role_menus', [
|
34
34
|
new TableForeignKey({
|
35
35
|
columnNames: ['role_id'],
|
36
36
|
referencedColumnNames: ['id'],
|
37
37
|
referencedTableName: 'roles',
|
38
38
|
onDelete: 'CASCADE',
|
39
|
-
name: '
|
39
|
+
name: 'fk_role_menus_roles',
|
40
40
|
}),
|
41
41
|
new TableForeignKey({
|
42
|
-
columnNames: ['
|
42
|
+
columnNames: ['menu_id'],
|
43
43
|
referencedColumnNames: ['id'],
|
44
|
-
referencedTableName: '
|
44
|
+
referencedTableName: 'menus',
|
45
45
|
onDelete: 'CASCADE',
|
46
|
-
name: '
|
46
|
+
name: 'fk_role_menus_menus',
|
47
47
|
}),
|
48
48
|
]);
|
49
49
|
}
|
50
50
|
|
51
51
|
async down(queryRunner: QueryRunner) {
|
52
|
-
await queryRunner.dropTable('
|
52
|
+
await queryRunner.dropTable('role_menus');
|
53
53
|
}
|
54
54
|
}
|
@@ -10,19 +10,19 @@ export class Migrate implements MigrationInterface {
|
|
10
10
|
async up(queryRunner: QueryRunner) {
|
11
11
|
await queryRunner.createTable(
|
12
12
|
new Table({
|
13
|
-
name: '
|
13
|
+
name: 'route_screens',
|
14
14
|
columns: [
|
15
15
|
{
|
16
|
-
name: '
|
16
|
+
name: 'route_id',
|
17
17
|
type: 'int',
|
18
|
-
isPrimary: true,
|
19
18
|
unsigned: true,
|
19
|
+
isPrimary: true,
|
20
20
|
},
|
21
21
|
{
|
22
|
-
name: '
|
22
|
+
name: 'screen_id',
|
23
23
|
type: 'int',
|
24
|
-
isPrimary: true,
|
25
24
|
unsigned: true,
|
25
|
+
isPrimary: true,
|
26
26
|
},
|
27
27
|
timestampColumn(),
|
28
28
|
timestampColumn('updated_at'),
|
@@ -30,26 +30,25 @@ export class Migrate implements MigrationInterface {
|
|
30
30
|
}),
|
31
31
|
);
|
32
32
|
|
33
|
-
await queryRunner.createForeignKeys('
|
33
|
+
await queryRunner.createForeignKeys('route_screens', [
|
34
34
|
new TableForeignKey({
|
35
|
-
columnNames: ['
|
35
|
+
columnNames: ['route_id'],
|
36
36
|
referencedColumnNames: ['id'],
|
37
|
-
referencedTableName: '
|
37
|
+
referencedTableName: 'routes',
|
38
38
|
onDelete: 'CASCADE',
|
39
|
-
name: '
|
39
|
+
name: 'fk_route_screens_routes',
|
40
40
|
}),
|
41
|
-
|
42
41
|
new TableForeignKey({
|
43
|
-
columnNames: ['
|
42
|
+
columnNames: ['screen_id'],
|
44
43
|
referencedColumnNames: ['id'],
|
45
|
-
referencedTableName: '
|
44
|
+
referencedTableName: 'screens',
|
46
45
|
onDelete: 'CASCADE',
|
47
|
-
name: '
|
46
|
+
name: 'fk_route_screens_screens',
|
48
47
|
}),
|
49
48
|
]);
|
50
49
|
}
|
51
50
|
|
52
51
|
async down(queryRunner: QueryRunner) {
|
53
|
-
await queryRunner.dropTable('
|
52
|
+
await queryRunner.dropTable('route_screens');
|
54
53
|
}
|
55
54
|
}
|
@@ -10,7 +10,7 @@ export class Migrate implements MigrationInterface {
|
|
10
10
|
async up(queryRunner: QueryRunner) {
|
11
11
|
await queryRunner.createTable(
|
12
12
|
new Table({
|
13
|
-
name: '
|
13
|
+
name: 'role_screens',
|
14
14
|
columns: [
|
15
15
|
{
|
16
16
|
name: 'role_id',
|
@@ -19,7 +19,7 @@ export class Migrate implements MigrationInterface {
|
|
19
19
|
unsigned: true,
|
20
20
|
},
|
21
21
|
{
|
22
|
-
name: '
|
22
|
+
name: 'screen_id',
|
23
23
|
type: 'int',
|
24
24
|
isPrimary: true,
|
25
25
|
unsigned: true,
|
@@ -30,25 +30,25 @@ export class Migrate implements MigrationInterface {
|
|
30
30
|
}),
|
31
31
|
);
|
32
32
|
|
33
|
-
await queryRunner.createForeignKeys('
|
33
|
+
await queryRunner.createForeignKeys('role_screens', [
|
34
34
|
new TableForeignKey({
|
35
35
|
columnNames: ['role_id'],
|
36
36
|
referencedColumnNames: ['id'],
|
37
37
|
referencedTableName: 'roles',
|
38
38
|
onDelete: 'CASCADE',
|
39
|
-
name: '
|
39
|
+
name: 'fk_role_screens_roles',
|
40
40
|
}),
|
41
41
|
new TableForeignKey({
|
42
|
-
columnNames: ['
|
42
|
+
columnNames: ['screen_id'],
|
43
43
|
referencedColumnNames: ['id'],
|
44
|
-
referencedTableName: '
|
44
|
+
referencedTableName: 'screens',
|
45
45
|
onDelete: 'CASCADE',
|
46
|
-
name: '
|
46
|
+
name: 'fk_role_screens_screens',
|
47
47
|
}),
|
48
48
|
]);
|
49
49
|
}
|
50
50
|
|
51
51
|
async down(queryRunner: QueryRunner) {
|
52
|
-
await queryRunner.dropTable('
|
52
|
+
await queryRunner.dropTable('role_screens');
|
53
53
|
}
|
54
54
|
}
|
@@ -1,26 +1,55 @@
|
|
1
|
-
import {
|
1
|
+
import { timestampColumn } from '@hedhog/utils';
|
2
|
+
import {
|
3
|
+
MigrationInterface,
|
4
|
+
QueryRunner,
|
5
|
+
Table,
|
6
|
+
TableForeignKey,
|
7
|
+
} from 'typeorm';
|
2
8
|
|
3
9
|
export class Migrate implements MigrationInterface {
|
4
10
|
async up(queryRunner: QueryRunner) {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
11
|
+
await queryRunner.createTable(
|
12
|
+
new Table({
|
13
|
+
name: 'role_users',
|
14
|
+
columns: [
|
15
|
+
{
|
16
|
+
name: 'role_id',
|
17
|
+
type: 'int',
|
18
|
+
isPrimary: true,
|
19
|
+
unsigned: true,
|
20
|
+
},
|
21
|
+
{
|
22
|
+
name: 'user_id',
|
23
|
+
type: 'int',
|
24
|
+
isPrimary: true,
|
25
|
+
unsigned: true,
|
26
|
+
},
|
27
|
+
timestampColumn(),
|
28
|
+
timestampColumn('updated_at'),
|
29
|
+
],
|
30
|
+
}),
|
31
|
+
);
|
10
32
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
33
|
+
await queryRunner.createForeignKeys('role_users', [
|
34
|
+
new TableForeignKey({
|
35
|
+
columnNames: ['role_id'],
|
36
|
+
referencedColumnNames: ['id'],
|
37
|
+
referencedTableName: 'roles',
|
38
|
+
onDelete: 'CASCADE',
|
39
|
+
name: 'fk_role_users_roles',
|
40
|
+
}),
|
41
|
+
|
42
|
+
new TableForeignKey({
|
43
|
+
columnNames: ['user_id'],
|
44
|
+
referencedColumnNames: ['id'],
|
45
|
+
referencedTableName: 'users',
|
46
|
+
onDelete: 'CASCADE',
|
47
|
+
name: 'fk_role_users_users',
|
48
|
+
}),
|
49
|
+
]);
|
21
50
|
}
|
22
51
|
|
23
52
|
async down(queryRunner: QueryRunner) {
|
24
|
-
await queryRunner.
|
53
|
+
await queryRunner.dropTable('role_users');
|
25
54
|
}
|
26
55
|
}
|
@@ -1,79 +1,54 @@
|
|
1
|
-
import {
|
1
|
+
import { timestampColumn } from '@hedhog/utils';
|
2
|
+
import {
|
3
|
+
MigrationInterface,
|
4
|
+
QueryRunner,
|
5
|
+
Table,
|
6
|
+
TableForeignKey,
|
7
|
+
} from 'typeorm';
|
2
8
|
|
3
9
|
export class Migrate implements MigrationInterface {
|
4
10
|
async up(queryRunner: QueryRunner) {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
.from('screens', 's')
|
44
|
-
.where('slug = :slug', { slug: '/management/settings' })
|
45
|
-
.execute();
|
46
|
-
|
47
|
-
for (const { url, screendId } of [
|
48
|
-
{ url: '/screens%', screendId: screenIdScreen[0].id },
|
49
|
-
{ url: '/roles%', screendId: screenIdRole[0].id },
|
50
|
-
{ url: '/users%', screendId: screenIdUser[0].id },
|
51
|
-
{ url: '/menus%', screendId: screenIdMenu[0].id },
|
52
|
-
{ url: '/routes%', screendId: screenIdRoute[0].id },
|
53
|
-
{ url: '/settings%', screendId: screenIdSetting[0].id },
|
54
|
-
]) {
|
55
|
-
const routesScreens = await queryRunner.manager
|
56
|
-
.createQueryBuilder()
|
57
|
-
.select()
|
58
|
-
.from('routes', 's')
|
59
|
-
.where('s.url LIKE :url', { url })
|
60
|
-
.execute();
|
61
|
-
|
62
|
-
for (const route of routesScreens) {
|
63
|
-
await queryRunner.manager
|
64
|
-
.createQueryBuilder()
|
65
|
-
.insert()
|
66
|
-
.into('route_screens')
|
67
|
-
.values({
|
68
|
-
route_id: route.id,
|
69
|
-
screen_id: screendId,
|
70
|
-
})
|
71
|
-
.execute();
|
72
|
-
}
|
73
|
-
}
|
11
|
+
await queryRunner.createTable(
|
12
|
+
new Table({
|
13
|
+
name: 'role_routes',
|
14
|
+
columns: [
|
15
|
+
{
|
16
|
+
name: 'role_id',
|
17
|
+
type: 'int',
|
18
|
+
isPrimary: true,
|
19
|
+
unsigned: true,
|
20
|
+
},
|
21
|
+
{
|
22
|
+
name: 'route_id',
|
23
|
+
type: 'int',
|
24
|
+
isPrimary: true,
|
25
|
+
unsigned: true,
|
26
|
+
},
|
27
|
+
timestampColumn(),
|
28
|
+
timestampColumn('updated_at'),
|
29
|
+
],
|
30
|
+
}),
|
31
|
+
);
|
32
|
+
|
33
|
+
await queryRunner.createForeignKeys('role_routes', [
|
34
|
+
new TableForeignKey({
|
35
|
+
columnNames: ['role_id'],
|
36
|
+
referencedColumnNames: ['id'],
|
37
|
+
referencedTableName: 'roles',
|
38
|
+
onDelete: 'CASCADE',
|
39
|
+
name: 'fk_role_routes_roles',
|
40
|
+
}),
|
41
|
+
new TableForeignKey({
|
42
|
+
columnNames: ['route_id'],
|
43
|
+
referencedColumnNames: ['id'],
|
44
|
+
referencedTableName: 'routes',
|
45
|
+
onDelete: 'CASCADE',
|
46
|
+
name: 'fk_role_routes_routes',
|
47
|
+
}),
|
48
|
+
]);
|
74
49
|
}
|
75
50
|
|
76
51
|
async down(queryRunner: QueryRunner) {
|
77
|
-
await queryRunner.
|
52
|
+
await queryRunner.dropTable('role_routes');
|
78
53
|
}
|
79
54
|
}
|
@@ -2,19 +2,25 @@ import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
2
|
|
3
3
|
export class Migrate implements MigrationInterface {
|
4
4
|
async up(queryRunner: QueryRunner) {
|
5
|
-
await queryRunner.manager
|
5
|
+
const menus = await queryRunner.manager
|
6
6
|
.createQueryBuilder()
|
7
|
-
.
|
8
|
-
.
|
9
|
-
.values([
|
10
|
-
{ role_id: 1, user_id: 1 },
|
11
|
-
{ role_id: 2, user_id: 2 },
|
12
|
-
])
|
7
|
+
.select()
|
8
|
+
.from('menus', 'm')
|
13
9
|
.execute();
|
10
|
+
|
11
|
+
for (const menu of menus) {
|
12
|
+
await queryRunner.manager
|
13
|
+
.createQueryBuilder()
|
14
|
+
.insert()
|
15
|
+
.into('role_menus')
|
16
|
+
.values({
|
17
|
+
role_id: 1,
|
18
|
+
menu_id: menu.id,
|
19
|
+
});
|
20
|
+
}
|
14
21
|
}
|
15
22
|
|
16
23
|
async down(queryRunner: QueryRunner) {
|
17
|
-
await queryRunner.manager.delete('
|
18
|
-
await queryRunner.manager.delete('role_users', { role_id: 2 });
|
24
|
+
await queryRunner.manager.delete('role_menus', { role_id: 1 });
|
19
25
|
}
|
20
26
|
}
|
@@ -2,56 +2,78 @@ import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
2
|
|
3
3
|
export class Migrate implements MigrationInterface {
|
4
4
|
async up(queryRunner: QueryRunner) {
|
5
|
-
const
|
5
|
+
const screenIdScreen = await queryRunner.manager
|
6
6
|
.createQueryBuilder()
|
7
7
|
.select()
|
8
|
-
.from('
|
8
|
+
.from('screens', 's')
|
9
|
+
.where('slug = :slug', { slug: '/management/screens' })
|
9
10
|
.execute();
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
const screenIdRole = await queryRunner.manager
|
13
|
+
.createQueryBuilder()
|
14
|
+
.select()
|
15
|
+
.from('screens', 's')
|
16
|
+
.where('slug = :slug', { slug: '/management/roles' })
|
17
|
+
.execute();
|
18
|
+
|
19
|
+
const screenIdUser = await queryRunner.manager
|
20
|
+
.createQueryBuilder()
|
21
|
+
.select()
|
22
|
+
.from('screens', 's')
|
23
|
+
.where('slug = :slug', { slug: '/management/users' })
|
24
|
+
.execute();
|
25
|
+
|
26
|
+
const screenIdMenu = await queryRunner.manager
|
27
|
+
.createQueryBuilder()
|
28
|
+
.select()
|
29
|
+
.from('screens', 's')
|
30
|
+
.where('slug = :slug', { slug: '/management/menus' })
|
31
|
+
.execute();
|
22
32
|
|
23
|
-
await queryRunner.manager
|
33
|
+
const screenIdRoute = await queryRunner.manager
|
24
34
|
.createQueryBuilder()
|
25
|
-
.
|
26
|
-
.
|
27
|
-
.
|
28
|
-
role_id: 2,
|
29
|
-
route_id: 3,
|
30
|
-
})
|
35
|
+
.select()
|
36
|
+
.from('screens', 's')
|
37
|
+
.where('slug = :slug', { slug: '/management/routes' })
|
31
38
|
.execute();
|
32
39
|
|
33
|
-
const
|
40
|
+
const screenIdSetting = await queryRunner.manager
|
34
41
|
.createQueryBuilder()
|
35
42
|
.select()
|
36
|
-
.from('
|
37
|
-
.where('
|
43
|
+
.from('screens', 's')
|
44
|
+
.where('slug = :slug', { slug: '/management/settings' })
|
38
45
|
.execute();
|
39
46
|
|
40
|
-
for (const
|
41
|
-
|
47
|
+
for (const { url, screendId } of [
|
48
|
+
{ url: '/screens%', screendId: screenIdScreen[0].id },
|
49
|
+
{ url: '/roles%', screendId: screenIdRole[0].id },
|
50
|
+
{ url: '/users%', screendId: screenIdUser[0].id },
|
51
|
+
{ url: '/menus%', screendId: screenIdMenu[0].id },
|
52
|
+
{ url: '/routes%', screendId: screenIdRoute[0].id },
|
53
|
+
{ url: '/settings%', screendId: screenIdSetting[0].id },
|
54
|
+
]) {
|
55
|
+
const routesScreens = await queryRunner.manager
|
42
56
|
.createQueryBuilder()
|
43
|
-
.
|
44
|
-
.
|
45
|
-
.
|
46
|
-
role_id: 2,
|
47
|
-
route_id: route.id,
|
48
|
-
})
|
57
|
+
.select()
|
58
|
+
.from('routes', 's')
|
59
|
+
.where('s.url LIKE :url', { url })
|
49
60
|
.execute();
|
61
|
+
|
62
|
+
for (const route of routesScreens) {
|
63
|
+
await queryRunner.manager
|
64
|
+
.createQueryBuilder()
|
65
|
+
.insert()
|
66
|
+
.into('route_screens')
|
67
|
+
.values({
|
68
|
+
route_id: route.id,
|
69
|
+
screen_id: screendId,
|
70
|
+
})
|
71
|
+
.execute();
|
72
|
+
}
|
50
73
|
}
|
51
74
|
}
|
52
75
|
|
53
76
|
async down(queryRunner: QueryRunner) {
|
54
|
-
await queryRunner.manager.delete('
|
55
|
-
await queryRunner.manager.delete('role_routes', { role_id: 2 });
|
77
|
+
await queryRunner.manager.delete('route_screens', {});
|
56
78
|
}
|
57
79
|
}
|