datai-vue/docs/api-docs/system/2026-01-21-002-05-03-api-切换货币.md
Kris a66ecad0f9 feat: 修复初始化从库接口参数并完善环境管理功能
- 更新 environment.js 中 initSlaveDatasource 函数参数从 environmentCode 改为 environmentId
- 更新 SourceEnvironmentTab.vue 中的初始化从库功能以使用 environmentId
- 在 TargetEnvironmentTab.vue 中添加完整的初始化从库功能
- 初始化项目单一真源(SSOT)文档结构,包括:
  - 创建主 index.md 作为项目单一真源
  - 创建 Authentication.canvas 可视化文件
  - 创建所有必需的文档目录和 README.md 文件
  - 建立完整的双向索引关系
2026-01-26 17:23:15 +08:00

88 lines
2.3 KiB
Markdown
Raw Permalink 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.

# API 文档:切换货币接口
## 元数据
- **需求编号**2026-01-21-002-05-03
- **创建时间**2026-01-26
- **创建人**SSOT 架构师
- **父需求**2026-01-21-002-05-货币格式化需求
## 接口概述
切换当前登录用户的货币偏好,更新用户货币设置,清除相关缓存,返回切换结果。货币切换后,前端需要刷新页面重新加载货币数据。
## 接口详情
### 基本信息
- **接口名称**:切换货币
- **接口描述**:切换当前登录用户的货币偏好
- **请求方式**POST
- **请求路径**`/system/currency/switch`
- **权限要求**:无(需要登录)
### 请求参数
| 参数名 | 类型 | 必选 | 说明 |
|--------|------|------|------|
| currencyCode | String | 是 | 货币代码(如 CNY、USD、EUR |
### 请求示例
```bash
curl -X POST 'http://localhost:8080/system/currency/switch' \
-H 'Authorization: Bearer {token}' \
-H 'Content-Type: application/json' \
-d '{
"currencyCode": "USD"
}'
```
### 响应数据结构
| 参数名 | 类型 | 说明 |
|--------|------|------|
| code | Integer | 状态码200 成功400/500 失败) |
| msg | String | 提示信息 |
| data | Object | 数据对象(通常为 null |
### 响应示例
**成功响应:**
```json
{
"code": 200,
"msg": "货币切换成功",
"data": null
}
```
**失败响应(无效的货币代码):**
```json
{
"code": 400,
"msg": "无效的货币代码",
"data": null
}
```
**失败响应(未找到用户信息):**
```json
{
"code": 500,
"msg": "未找到用户信息",
"data": null
}
```
### 业务规则
1. 验证货币代码的有效性
2. 更新用户货币偏好到数据库
3. 清除用户货币缓存
4. 清除相关数据缓存(如汇率缓存等)
5. 货币切换后,前端需要刷新页面重新加载货币数据
6. 货币切换记录审计日志
7. 货币切换响应时间 < 500ms
### 性能要求
- **响应时间**< 500ms
- **数据库更新时间**< 100ms
### 相关文档
- [需求文档](file:///d:/idea_demo/datai/datai-scenes/datai-scene-salesforce/docs/requirements/2026-01-21-002-05-货币格式化需求.md)
- [设计文档](file:///d:/idea_demo/datai/datai-scenes/datai-scene-salesforce/docs/design/2026-01-21-002-05-货币格式化设计.md)