@saihu/common 1.1.83 → 1.1.84
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/README.md
CHANGED
|
@@ -15,9 +15,11 @@ npm install @saihu/common
|
|
|
15
15
|
PermissionGuard 是一个基于 NestJS 的权限守卫,用于验证用户是否有权限访问特定接口。它支持角色验证和权限验证两种方式。
|
|
16
16
|
|
|
17
17
|
#### 依赖服务
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
- redis
|
|
19
20
|
|
|
20
21
|
#### 功能特点
|
|
22
|
+
|
|
21
23
|
- 支持基于角色(Roles)的权限验证
|
|
22
24
|
- 支持基于权限(Perms)的细粒度权限验证
|
|
23
25
|
- 支持公共接口标记
|
|
@@ -39,6 +41,7 @@ PermissionGuard 通过以下装饰器来定义接口的权限要求:
|
|
|
39
41
|
```
|
|
40
42
|
|
|
41
43
|
#### 配置选项
|
|
44
|
+
|
|
42
45
|
在 `CommonModuleOptions` 中可以配置 PermissionGuard 的行为:
|
|
43
46
|
|
|
44
47
|
```typescript
|
|
@@ -63,8 +66,8 @@ import { SaihuCommonModule } from '@saihu/common';
|
|
|
63
66
|
name: 'your-app-name',
|
|
64
67
|
usePerms: true, // 启用权限校验
|
|
65
68
|
// 其他配置...
|
|
66
|
-
})
|
|
67
|
-
]
|
|
69
|
+
}),
|
|
70
|
+
],
|
|
68
71
|
})
|
|
69
72
|
export class AppModule {}
|
|
70
73
|
```
|
|
@@ -106,13 +109,15 @@ export class UserController {
|
|
|
106
109
|
OperlogInterceptor 是一个操作日志拦截器,用于自动记录用户的操作行为,包括请求参数、响应结果、执行时间等信息。它会将日志通过 RabbitMQ 发送到消息队列。
|
|
107
110
|
|
|
108
111
|
#### 功能特点
|
|
112
|
+
|
|
109
113
|
- 自动记录 HTTP 请求的详细信息
|
|
110
114
|
- 支持白名单配置,可以排除特定 URL
|
|
111
|
-
- 记录用户信息、IP地址、请求参数、响应结果等
|
|
115
|
+
- 记录用户信息、IP 地址、请求参数、响应结果等
|
|
112
116
|
- 记录请求处理时间
|
|
113
117
|
- 通过 RabbitMQ 异步发送日志
|
|
114
118
|
|
|
115
119
|
#### 配置选项
|
|
120
|
+
|
|
116
121
|
在 `CommonModuleOptions` 中可以配置 OperlogInterceptor 的行为:
|
|
117
122
|
|
|
118
123
|
```typescript
|
|
@@ -146,10 +151,10 @@ import { SaihuCommonModule } from '@saihu/common';
|
|
|
146
151
|
useOperlog: true, // 启用操作日志
|
|
147
152
|
operlogWhitelist: ['/health', '/metrics'], // 排除健康检查和监控接口
|
|
148
153
|
rabbitmq: {
|
|
149
|
-
url: 'amqp://localhost:5672'
|
|
150
|
-
}
|
|
151
|
-
})
|
|
152
|
-
]
|
|
154
|
+
url: 'amqp://localhost:5672',
|
|
155
|
+
},
|
|
156
|
+
}),
|
|
157
|
+
],
|
|
153
158
|
})
|
|
154
159
|
export class AppModule {}
|
|
155
160
|
```
|
|
@@ -187,12 +192,12 @@ SaihuCommonModule.forRoot({
|
|
|
187
192
|
operlogWhitelist: ['/health'],
|
|
188
193
|
redis: {
|
|
189
194
|
url: 'redis://localhost:6379',
|
|
190
|
-
password: 'your-redis-password'
|
|
195
|
+
password: 'your-redis-password',
|
|
191
196
|
},
|
|
192
197
|
rabbitmq: {
|
|
193
|
-
url: 'amqp://localhost:5672'
|
|
194
|
-
}
|
|
195
|
-
})
|
|
198
|
+
url: 'amqp://localhost:5672',
|
|
199
|
+
},
|
|
200
|
+
});
|
|
196
201
|
```
|
|
197
202
|
|
|
198
203
|
### 异步配置
|
|
@@ -215,4 +220,4 @@ SaihuCommonModule.forRootAsync({
|
|
|
215
220
|
// 需要额外注册全局的APP_INTERCEPTOR
|
|
216
221
|
SaihuCommonModule.withOperlogInterceptor()
|
|
217
222
|
})
|
|
218
|
-
```
|
|
223
|
+
```
|
|
@@ -19,6 +19,7 @@ export declare enum Exchanges {
|
|
|
19
19
|
}
|
|
20
20
|
export declare const RoutingKeys: {
|
|
21
21
|
readonly "im.procurement.order": {
|
|
22
|
+
readonly ORDER_CREATED: "procurement.order.created";
|
|
22
23
|
readonly ORDER_DELIVERED: "procurement.order.delivered";
|
|
23
24
|
readonly RETURN_PROCESSED: "procurement.order.return.processed";
|
|
24
25
|
readonly RETURN_DETAIL_APPROVED: "procurement.order.return.detail.approved";
|
|
@@ -26,6 +27,7 @@ export declare const RoutingKeys: {
|
|
|
26
27
|
readonly ORDER_CHECK_PASSED: "procurement.order.check.passed";
|
|
27
28
|
};
|
|
28
29
|
readonly "im.procurement.order.dlx": {
|
|
30
|
+
readonly ORDER_CREATED: "procurement.order.created.dlq";
|
|
29
31
|
readonly ORDER_DELIVERED: "procurement.order.delivered.dlq";
|
|
30
32
|
readonly RETURN_PROCESSED: "procurement.order.return.processed.dlq";
|
|
31
33
|
readonly RETURN_DETAIL_APPROVED: "procurement.order.return.detail.approved.dlq";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topology.d.ts","sourceRoot":"","sources":["../../src/messaging/topology.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAErE,oBAAY,SAAS;IACnB,oBAAoB,yBAAyB;IAC7C,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;IACjC,OAAO,YAAY;IACnB,WAAW,gBAAgB;IAC3B,iBAAiB,sBAAsB;IACvC,QAAQ,aAAa;IACrB,qBAAqB,0BAA0B;IAG/C,wBAAwB,6BAA6B;IACrD,gBAAgB,qBAAqB;IACrC,kBAAkB,uBAAuB;IACzC,WAAW,gBAAgB;IAC3B,eAAe,oBAAoB;IACnC,qBAAqB,0BAA0B;IAC/C,YAAY,iBAAiB;IAC7B,yBAAyB,8BAA8B;CACxD;AAED,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"topology.d.ts","sourceRoot":"","sources":["../../src/messaging/topology.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAA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ROCUREMENT_ORDER]: {
|
|
26
|
+
ORDER_CREATED: 'procurement.order.created',
|
|
26
27
|
ORDER_DELIVERED: 'procurement.order.delivered',
|
|
27
28
|
RETURN_PROCESSED: 'procurement.order.return.processed',
|
|
28
29
|
RETURN_DETAIL_APPROVED: 'procurement.order.return.detail.approved',
|
|
@@ -30,6 +31,7 @@ exports.RoutingKeys = {
|
|
|
30
31
|
ORDER_CHECK_PASSED: 'procurement.order.check.passed',
|
|
31
32
|
},
|
|
32
33
|
[Exchanges.IM_PROCUREMENT_ORDER_DLX]: {
|
|
34
|
+
ORDER_CREATED: 'procurement.order.created.dlq',
|
|
33
35
|
ORDER_DELIVERED: 'procurement.order.delivered.dlq',
|
|
34
36
|
RETURN_PROCESSED: 'procurement.order.return.processed.dlq',
|
|
35
37
|
RETURN_DETAIL_APPROVED: 'procurement.order.return.detail.approved.dlq',
|