Skip to content

Commit ff4892b

Browse files
committed
🗃️ feat: add migration sql
1 parent 75bfc19 commit ff4892b

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

backend/apps/base-system/src/lib/bounded-contexts/api-endpoint/api-endpoint/application/event-handlers/api-endpoint.event.handler.ts

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ export class ApiEndpointEventHandler implements OnModuleInit {
1717
private readonly eventEmitter: EventEmitter2,
1818
) {}
1919

20+
/**
21+
* 模块初始化时执行的方法
22+
* 这里我们手动注册事件监听器,以确保能捕获到 API_ENDPOINT 事件
23+
* 这种方法可以解决 @OnEvent 装饰器在某些情况下不生效的问题
24+
* 或者另一种方案是在app.module.ts中将BootstrapModule放在最后,这样在模块初始化时,API_ENDPOINT事件已经emit了
25+
*/
2026
onModuleInit() {
2127
this.logger.log('ApiEndpointEventHandler initialized');
2228
this.eventEmitter.on(API_ENDPOINT, this.handleManually.bind(this));

backend/prisma/seeds/sys/casbinRule.ts

+63
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,69 @@ export const initCasbinRule = async () => {
1313
v4: null,
1414
v5: null,
1515
},
16+
{
17+
ptype: 'p',
18+
v0: 'ROLE_SUPER',
19+
v1: 'authorization',
20+
v2: 'assign-routes',
21+
v3: 'built-in',
22+
v4: null,
23+
v5: null,
24+
},
25+
{
26+
ptype: 'p',
27+
v0: 'ROLE_SUPER',
28+
v1: 'authorization',
29+
v2: 'assign-users',
30+
v3: 'built-in',
31+
v4: null,
32+
v5: null,
33+
},
34+
{
35+
ptype: 'p',
36+
v0: 'ROLE_SUPER',
37+
v1: 'api-endpoint',
38+
v2: 'read',
39+
v3: 'built-in',
40+
v4: null,
41+
v5: null,
42+
},
43+
{
44+
ptype: 'p',
45+
v0: 'ROLE_SUPER',
46+
v1: 'login-log',
47+
v2: 'read',
48+
v3: 'built-in',
49+
v4: null,
50+
v5: null,
51+
},
52+
{
53+
ptype: 'p',
54+
v0: 'ROLE_SUPER',
55+
v1: 'operation-log',
56+
v2: 'read',
57+
v3: 'built-in',
58+
v4: null,
59+
v5: null,
60+
},
61+
{
62+
ptype: 'p',
63+
v0: 'ROLE_ADMIN',
64+
v1: 'login-log',
65+
v2: 'read',
66+
v3: 'built-in',
67+
v4: null,
68+
v5: null,
69+
},
70+
{
71+
ptype: 'p',
72+
v0: 'ROLE_ADMIN',
73+
v1: 'operation-log',
74+
v2: 'read',
75+
v3: 'built-in',
76+
v4: null,
77+
v5: null,
78+
},
1679
];
1780

1881
return prisma.casbinRule.createMany({ data });

deploy/postgres/08_casbin_rule.sql

+7
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
INSERT INTO public.casbin_rule (id, ptype, v0, v1, v2, v3, v4, v5) VALUES (1, 'p', 'ROLE_SUPER', 'authorization', 'assign-permission', 'built-in', null, null);
2+
INSERT INTO public.casbin_rule (id, ptype, v0, v1, v2, v3, v4, v5) VALUES (2, 'p', 'ROLE_SUPER', 'authorization', 'assign-routes', 'built-in', null, null);
3+
INSERT INTO public.casbin_rule (id, ptype, v0, v1, v2, v3, v4, v5) VALUES (3, 'p', 'ROLE_SUPER', 'authorization', 'assign-users', 'built-in', null, null);
4+
INSERT INTO public.casbin_rule (id, ptype, v0, v1, v2, v3, v4, v5) VALUES (4, 'p', 'ROLE_SUPER', 'api-endpoint', 'read', 'built-in', null, null);
5+
INSERT INTO public.casbin_rule (id, ptype, v0, v1, v2, v3, v4, v5) VALUES (5, 'p', 'ROLE_SUPER', 'login-log', 'read', 'built-in', null, null);
6+
INSERT INTO public.casbin_rule (id, ptype, v0, v1, v2, v3, v4, v5) VALUES (6, 'p', 'ROLE_SUPER', 'operation-log', 'read', 'built-in', null, null);
7+
INSERT INTO public.casbin_rule (id, ptype, v0, v1, v2, v3, v4, v5) VALUES (7, 'p', 'ROLE_ADMIN', 'login-log', 'read', 'built-in', null, null);
8+
INSERT INTO public.casbin_rule (id, ptype, v0, v1, v2, v3, v4, v5) VALUES (8, 'p', 'ROLE_ADMIN', 'operation-log', 'read', 'built-in', null, null);

0 commit comments

Comments
 (0)