datai/docs/archive/api-docs/auth/DataiSfLoginHistoryController/0007-latest-success-grouped.md

103 lines
2.5 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.

# 查询所有登录成功历史分组数据
## 接口信息
- **接口路径**: `GET /auth/history/latest-success-grouped`
- **接口描述**: 查询所有登录成功的历史记录按username和instanceUrl分组每组返回最新一条数据
- **权限要求**: `auth:history:list`
- **请求类型**: GET
## 请求参数
## 响应数据
### 成功响应
```json
{
"code": 200,
"message": "查询成功",
"rows": [
{
"id": 1,
"loginType": "password",
"username": "admin@example.com",
"passwordEncrypted": null,
"securityTokenEncrypted": null,
"clientId": null,
"clientSecretEncrypted": null,
"grantType": null,
"orgAlias": null,
"privateKeyPath": null,
"code": null,
"state": null,
"sessionId": "xxxxx",
"environmentCode": null,
"environmentId": null,
"instanceUrl": "https://xxx.my.salesforce.com",
"organizationId": "00Dxxxxxxxxxxxx",
"orgType": "Source",
"requestIp": "192.168.1.1",
"requestPort": 8080,
"userAgent": "Mozilla/5.0",
"deviceType": "PC",
"browserType": "Chrome",
"osType": "Windows",
"loginStatus": "success",
"errorCode": null,
"errorMessage": null,
"sessionIdResult": "xxxxx",
"refreshTokenEncrypted": null,
"tokenType": "Bearer",
"expiresIn": 3600,
"requestTime": "2026-01-16 10:00:00",
"responseTime": "2026-01-16 10:00:01",
"durationMs": 1000,
"operator": "admin",
"deptId": 1,
"createBy": "admin",
"createTime": "2026-01-16 10:00:01",
"updateBy": "admin",
"updateTime": "2026-01-16 10:00:01",
"remark": null
}
],
"total": 1
}
```
### 失败响应
```json
{
"code": 500,
"message": "查询失败",
"data": null
}
```
## 功能说明
1. **分组逻辑**: 按照用户名username和实例URLinstanceUrl进行分组
2. **最新记录**: 每个分组只返回创建时间最新的一条记录
3. **登录状态**: 只返回登录状态为 success 的记录
4. **数据转换**: 返回的数据会自动转换为 VO 对象
## 使用场景
- 查看不同用户在不同环境下的最新登录记录
- 快速了解系统中的活跃用户和环境
- 用于登录历史分析和统计
## 相关接口
- [查询登录历史信息列表](./0001-list.md)
- [获取登录历史信息详细信息](./0003-get-info.md)
## 相关文档
- [需求文档](../../../requirements/REQ-007.md)
- [架构决策](../../../decisions/adr/0007-login-history-query-and-auto-login.md)