feat: scaffold independent workbench service
This commit is contained in:
@@ -1,3 +1,88 @@
|
||||
# im_workbench
|
||||
|
||||
im工作台代码
|
||||
工作台服务从 `im_server` 拆分后的独立 Go 工程。当前阶段只拆服务和接口边界,数据库暂不迁移,继续访问现有租户库中的工作台表。
|
||||
|
||||
## 路由
|
||||
|
||||
- `GET /healthz`
|
||||
- `GET /metrics`
|
||||
- `GET /v1/workbench`
|
||||
- `/v1/workbench/organization/*`
|
||||
- `/v1/workbench/attendance/*`
|
||||
- `/v1/workbench/meetings*`
|
||||
- `/v1/workbench/meeting-notes`
|
||||
- `/v1/workbench/reports/daily*`
|
||||
- `/v1/workbench/reports/monthly*`
|
||||
- `/v1/workbench/executive-mailbox/*`
|
||||
|
||||
## 本地运行
|
||||
|
||||
```bash
|
||||
IM_WORKBENCH_CONFIG=configs/workbench.local.json go run ./cmd/workbench
|
||||
```
|
||||
|
||||
默认监听 `:6061`,默认连接本地 `tinode` 库和本地 Redis。
|
||||
|
||||
开发联调可在 `configs/workbench.local.json` 打开 `allow_dev_header_auth`,请求头带:
|
||||
|
||||
```text
|
||||
X-User-ID: 1
|
||||
X-Tenant-ID: 1
|
||||
X-Tenant-Code: default
|
||||
```
|
||||
|
||||
正式链路使用:
|
||||
|
||||
```text
|
||||
Authorization: Bearer {token}
|
||||
X-MeetingIM-APIKey: {apikey}
|
||||
X-Tenant-Code: default
|
||||
X-IM-Schema: 1
|
||||
X-Request-ID: {uuid}
|
||||
```
|
||||
|
||||
服务从 Redis 读取 `im:session:token:{sha256(token)}` 校验登录态。
|
||||
|
||||
## Kafka 事件
|
||||
|
||||
工作台写操作统一投递到 `im.workbench.event`。本地配置默认关闭 Kafka:
|
||||
|
||||
```bash
|
||||
IM_WORKBENCH_KAFKA_ENABLED=true \
|
||||
IM_WORKBENCH_KAFKA_BROKERS=127.0.0.1:9092 \
|
||||
IM_WORKBENCH_CONFIG=configs/workbench.local.json \
|
||||
go run ./cmd/workbench
|
||||
```
|
||||
|
||||
测试环境使用 `configs/workbench.test.json` 中的 SASL/SCRAM-SHA-512 配置。
|
||||
|
||||
事件体字段:
|
||||
|
||||
```json
|
||||
{
|
||||
"event_id": "wbe_xxx",
|
||||
"trace_id": "request-id",
|
||||
"tenant_id": 1,
|
||||
"tenant_code": "default",
|
||||
"actor_user_id": 42,
|
||||
"module": "meeting",
|
||||
"action": "meeting.created",
|
||||
"resource_id": "mtg_xxx",
|
||||
"target_user_ids": [42, 43],
|
||||
"title": "会议通知",
|
||||
"summary": "项目周会",
|
||||
"occurred_at": "2026-09-13T14:00:00Z",
|
||||
"data": {}
|
||||
}
|
||||
```
|
||||
|
||||
## 构建
|
||||
|
||||
```bash
|
||||
make test
|
||||
make build
|
||||
```
|
||||
|
||||
## 数据库原则
|
||||
|
||||
服务启动不自动建库建表,不执行 `CREATE TABLE` / `ALTER TABLE`。所有表结构和种子数据继续通过 SQL 审核后人工执行。
|
||||
|
||||
Reference in New Issue
Block a user