Files
cn-rdms/rdms-system/rdms-system-api/README.md
2026-03-12 16:25:24 +08:00

58 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# rdms-system-api
**概述**
本模块定义了 System系统模块对其他模块开放的公共 RPC API 面。它是一个纯 API 的 jar 包:包含 Feign 客户端接口、请求/响应 DTO以及枚举/常量。不包含 controller 或 service 的实现。
**这里包含什么**
- 位于 `com.njcn.rdms.module.system.api.*` 下的 Feign 客户端接口
- 位于 `com.njcn.rdms.module.system.api.*.dto` 下的 DTO
- 位于 `com.njcn.rdms.module.system.enums.*` 下的系统枚举和常量
**API 分组**
- `config``ConfigApi`,用于根据 key 读取配置值
- `dept``DeptApi``PostApi`,用于部门与岗位数据及校验
- `dict``DictDataApi`,用于字典数据校验(继承 `DictDataCommonApi`
- `file``FileApi`,用于文件创建与预签名 URL
- `logger``LoginLogApi``OperateLogApi`(继承 `OperateLogCommonApi`
- `notify``NotifyMessageSendApi`,用于站内消息发送
- `permission``PermissionApi`(继承 `PermissionCommonApi`)以及 `RoleApi`
- `user``AdminUserApi`,用于管理员用户查询与校验
- `websocket``WebSocketSenderApi`,用于推送 WebSocket 消息
**关键常量**
- `ApiConstants.NAME = "system-server"`(必须与 system 服务的 `spring.application.name` 保持一致)
- `ApiConstants.PREFIX = "/rpc-api/system"`
- `ApiConstants.VERSION = "1.0.0"`
**用法**
1. 在调用方模块中添加依赖。
```xml
<dependency>
<groupId>com.njcn</groupId>
<artifactId>rdms-system-api</artifactId>
</dependency>
```
2. 在调用方服务中启用 Feign 客户端扫描。
```java
@EnableFeignClients(basePackages = "com.njcn.rdms.module.system.api")
```
3. 注入并调用 API 接口。
```java
@Resource
private AdminUserApi adminUserApi;
public AdminUserRespDTO loadUser(Long id) {
return adminUserApi.getUser(id).getCheckedData();
}
```
**备注**
- 所有方法都返回 `CommonResult<T>`。按需使用 `getCheckedData()``checkError()`
- 有些 API 提供了默认的辅助方法(例如 `FileApi.createFile(...)``WebSocketSenderApi.send(...)`)。
- `DictDataApi``OperateLogApi``PermissionApi` 继承了来自 `rdms-framework` 的通用 RPC 接口。