You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.8 KiB
Markdown

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# EMS Node Login Server
这是 Java 后端核心接口的 Node.js 重写版本,放在 `server-node` 下独立运行。
## 已实现
- `POST /auth/login`
- `GET /auth/code`
- `POST /auth/logout`
- `GET /auth/tenant/list`
- `GET /system/user/getInfo`
- `GET /system/menu/getRouters`
- `/system/menu/**`
- `/system/user/**`
- `/system/role/**`
- `/system/dept/**`
- `/system/post/**`
- `/system/dict/type/**`
- `/system/dict/data/**`
- `/system/config/**`
- `/system/notice/**`
- `/system/client/**`
- `/system/tenant/**`
- `/system/tenant/package/**`
- `/system/social/list`
- `/resource/oss/**`
- `/resource/oss/config/**`
- `/resource/sse/close`
- `/monitor/cache/**`
- `/monitor/operlog/**`
- `/monitor/logininfor/**`
- `/monitor/online/**`
- `/demo/demo/**`
- `/demo/tree/**`
- `/workflow/category/**`
- `/workflow/spel/**`
- `/workflow/leave/**`
- `/workflow/definition/**`
- `/workflow/instance/**`
- `/workflow/task/**`
- `/tool/gen/**`
- `GET /health`
登录接口兼容 Java 返回结构:
```json
{
"code": 200,
"msg": "操作成功",
"data": {
"access_token": "...",
"refresh_token": null,
"expire_in": 604800,
"refresh_expire_in": null,
"client_id": "...",
"scope": null,
"openid": null
}
}
```
## 运行
```bash
yarn install
yarn start
```
默认端口:`3000`。
默认数据库名:`scrin_ems`。如果云数据库使用其他库名,修改 `.env` 中的 `DB_NAME`
## 请求示例
```bash
curl -X POST http://localhost:3000/auth/login \
-H 'Content-Type: application/json' \
-d '{
"tenantId": "000000",
"clientId": "e5cd7e4891bf95d1d19206ce24a7b32e",
"grantType": "password",
"username": "admin",
"password": "admin123"
}'
```
## 注意
- 当前只实现 `grantType=password`
- `/auth/code` 已实现数学验证码,验证码答案保存在 Node 进程内 TTL 缓存中;多实例部署时建议改成 Redis。
- Java 原版使用 Sa-Token此版本使用 JWT所以后续 Node 接口可直接验证 JWT但 Java 原接口不会自动识别这个 token。
- `/system/user/getInfo`、`/system/menu/getRouters` 和 `ui/src/api/system` 中声明的系统管理接口已按前端当前调用路径实现,读取 `Authorization: Bearer <token>`
- 导出类接口当前返回空文件占位,头像上传和 OSS 文件下载仍是基础占位实现;如果要生产使用,需要继续接入实际文件存储和 Excel 导出。
- 服务启动时会先执行 `select 1` 验证数据库连接;连接成功后才监听端口,并每 30 秒执行一次数据库心跳保持连接池活跃。
- 工作流模块当前覆盖前端接口路径和基础数据表读写;流程启动、办理、驳回等 WarmFlow 引擎内部流转为轻量占位实现。
- `.env` 存放真实数据库配置,已被 `.gitignore` 忽略。