初始化小程序端

This commit is contained in:
2025-12-11 11:06:11 +08:00
parent a2c0d17210
commit f9988ae675
531 changed files with 235994 additions and 114 deletions

View File

@@ -173,7 +173,56 @@
## 2. Check控制器接口
### 2.1 添加会话记录接口
### 2.1 检查地址接口
#### 接口描述
根据会话记录的GUID查询经纬度信息并转换为详细地址更新到数据库中。
#### 接口路径
`/api/Check/CheckAddress`
#### 请求参数
| 参数名 | 类型 | 必填 | 描述 |
|--------|------|------|------|
| Guid | string | 是 | 会话唯一标识 |
#### 请求示例
```json
{
"Guid": "会话唯一标识"
}
```
#### 响应示例
**成功响应:**
```json
{
"success": true,
"message": "地址更新成功",
"address": "北京市海淀区中关村南大街5号"
}
```
**失败响应:**
```json
{
"success": false,
"message": "记录不存在或已被删除"
}
```
```json
{
"success": false,
"message": "更新失败",
"error": "数据库操作错误"
}
```
### 2.2 添加会话记录接口
#### 接口描述
添加新的会话记录到系统中。
@@ -188,8 +237,9 @@
| UserKey | string | 是 | 用户唯一标识键 |
| ConversationContent | string | 是 | 会话内容 |
| SendMethod | string | 是 | 发送方式 |
| UserLocation | string | 否 | 用户定位信息 |
| UserLocation | string | 否 | 用户定位信息(经纬度格式:"纬度,经度" |
| MessageType | int | 否 | 1:公有消息2:私有消息 |
| Guid | string | 否 | 会话唯一标识(不提供则系统自动生成) |
#### 请求示例
@@ -198,8 +248,8 @@
"UserKey": "user_123456",
"ConversationContent": "这是一条测试消息",
"SendMethod": "文本",
"UserLocation": "北京市海淀区",
"MessageType": 0
"UserLocation": "39.9087,116.3975",
"MessageType": 1
}
```
@@ -209,7 +259,9 @@
```json
{
"success": true,
"message": "收到!"
"message": "收到!",
"conversationGuid": "会话唯一标识",
"receivedTime": "2023-10-31 10:05:00"
}
```
@@ -222,7 +274,7 @@
}
```
### 2.2 查询会话记录接口
### 2.3 查询会话记录接口
#### 接口描述
根据用户唯一标识键查询该用户的所有会话记录。
@@ -255,27 +307,33 @@
"data": [
{
"Id": 1,
"Guid": "会话唯一标识",
"UserKey": "user_123456",
"ConversationContent": "这是一条测试消息",
"SendMethod": "文本",
"UserLocation": "北京市海淀区",
"Latitude": "39.9087",
"Longitude": "116.3975",
"RecordTime": "2023-10-31T10:05:00",
"RecordTimeUTCStamp": 1698732300000,
"IsDeleted": false,
"CreateTime": "2023-10-31T10:05:00",
"MessageType": 0
"MessageType": 1
},
{
"Id": 2,
"Guid": "会话唯一标识",
"UserKey": "user_123456",
"ConversationContent": "这是第二条测试消息",
"SendMethod": "图片",
"UserLocation": "北京市朝阳区",
"Latitude": "39.9180",
"Longitude": "116.4272",
"RecordTime": "2023-10-31T10:06:00",
"RecordTimeUTCStamp": 1698732360000,
"IsDeleted": false,
"CreateTime": "2023-10-31T10:06:00",
"MessageType": 1
"MessageType": 2
}
]
}
@@ -290,7 +348,7 @@
}
```
### 2.3 分页查询会话记录接口
### 2.4 分页查询会话记录接口
#### 接口描述
分页查询用户的会话记录每页默认10条按时间戳从**最新到最旧**排序,支持根据消息类型进行过滤。
@@ -328,27 +386,33 @@
"conversations": [
{
"Id": 1,
"Guid": "会话唯一标识",
"UserKey": "user_123456",
"ConversationContent": "这是一条测试消息",
"SendMethod": "文本",
"UserLocation": "北京市海淀区",
"Latitude": "39.9087",
"Longitude": "116.3975",
"RecordTime": "2023-10-31T10:00:00",
"RecordTimeUTCStamp": 1698727200000,
"IsDeleted": false,
"CreateTime": "2023-10-31T10:00:00",
"MessageType": 0
"MessageType": 1
},
{
"Id": 2,
"Guid": "会话唯一标识",
"UserKey": "user_123456",
"ConversationContent": "这是一条私有消息",
"SendMethod": "文本",
"UserLocation": "北京市朝阳区",
"Latitude": "39.9180",
"Longitude": "116.4272",
"RecordTime": "2023-10-31T09:55:00",
"RecordTimeUTCStamp": 1698724500000,
"IsDeleted": false,
"CreateTime": "2023-10-31T09:55:00",
"MessageType": 1
"MessageType": 2
}
],
"totalCount": 25,
@@ -368,10 +432,73 @@
}
```
### 2.3 更新会话记录接口
### 2.5 根据GUID查询会话记录接口
#### 接口描述
更新指定ID的会话记录需要验证UserKey的权限
根据会话唯一标识GUID查询会话记录详情不考虑IsDeleted状态
#### 接口路径
`/api/Check/GetConversationByGuid`
#### 请求参数
| 参数名 | 类型 | 必填 | 描述 |
|--------|------|------|------|
| Guid | string | 是 | 会话唯一标识 |
#### 请求示例
```json
{
"Guid": "会话唯一标识"
}
```
#### 响应示例
**成功响应:**
```json
{
"success": true,
"message": "查询成功",
"data": {
"Id": 1,
"Guid": "会话唯一标识",
"UserKey": "user_123456",
"ConversationContent": "这是一条测试消息",
"SendMethod": "文本",
"UserLocation": "北京市海淀区",
"Latitude": "39.9087",
"Longitude": "116.3975",
"RecordTime": "2023-10-31T10:05:00",
"RecordTimeUTCStamp": 1698732300000,
"IsDeleted": false,
"CreateTime": "2023-10-31T10:05:00",
"MessageType": 1
}
}
```
**失败响应:**
```json
{
"success": false,
"message": "未找到该记录"
}
```
```json
{
"success": false,
"message": "查询失败",
"error": "数据库操作错误"
}
```
### 2.6 更新会话记录接口
#### 接口描述
更新指定GUID的会话记录需要验证UserKey的权限。每次更新时RecordTime会自动更新为当前时间。
#### 接口路径
`/api/Check/UpdateConversation`
@@ -380,7 +507,7 @@
| 参数名 | 类型 | 必填 | 描述 |
|--------|------|------|------|
| Id | long | 是 | 会话记录ID |
| Guid | string | 是 | 会话唯一标识 |
| UserKey | string | 是 | 用户唯一标识键(用于权限验证) |
| ConversationContent | string | 是 | 新的会话内容 |
| SendMethod | string | 是 | 新的发送方式 |
@@ -391,12 +518,12 @@
```json
{
"Id": 1,
"Guid": "会话唯一标识",
"UserKey": "user_123456",
"ConversationContent": "更新后的会话内容",
"SendMethod": "文本",
"UserLocation": "北京市西城区",
"MessageType": 0
"MessageType": 1
}
```
@@ -406,7 +533,8 @@
```json
{
"success": true,
"message": "会话更新成功"
"message": "更新成功",
"receivedTime": "2023-10-31 10:10:00"
}
```
@@ -414,7 +542,7 @@
```json
{
"success": false,
"message": "会话记录不存在或无权限修改"
"message": "记录不存在或无权限修改"
}
```
@@ -426,7 +554,7 @@
}
```
### 2.4 删除会话记录接口
### 2.7 删除会话记录接口
#### 接口描述
软删除会话记录将IsDeleted标记为1需要验证UserKey的权限。
@@ -438,14 +566,14 @@
| 参数名 | 类型 | 必填 | 描述 |
|--------|------|------|------|
| Id | long | 是 | 会话记录ID |
| Guid | string | 是 | 会话唯一标识 |
| UserKey | string | 是 | 用户唯一标识键(用于权限验证) |
#### 请求示例
```json
{
"Id": 1,
"Guid": "会话唯一标识",
"UserKey": "user_123456"
}
```
@@ -456,7 +584,7 @@
```json
{
"success": true,
"message": "会话删除成功"
"message": "删除成功"
}
```
@@ -464,7 +592,7 @@
```json
{
"success": false,
"message": "会话记录不存在或已被删除"
"message": "记录不存在或已被删除"
}
```
@@ -476,6 +604,73 @@
}
```
### 2.8 从Redis Stream读取消息接口
#### 接口描述
从Redis Stream读取新的会话消息。
#### 接口路径
`/api/Check/ReadMessageFromRedis`
#### 请求参数
| 参数名 | 类型 | 必填 | 描述 |
|--------|------|------|------|
| GroupName | string | 否 | 消费组名称默认xcx_group |
| ConsumerName | string | 否 | 消费者名称默认consumer_时间戳 |
| Count | int | 否 | 读取消息数量默认1 |
#### 请求示例
```json
{
"GroupName": "xcx_group",
"ConsumerName": "consumer_1",
"Count": 5
}
```
#### 响应示例
**成功响应:**
```json
{
"success": true,
"message": "成功读取消息",
"data": [
{
"MessageId": "1635739200000-0",
"Id": "1",
"Guid": "会话唯一标识",
"UserKey": "user_123456",
"ConversationContent": "测试消息",
"SendMethod": "文本",
"UserLocation": "北京市海淀区",
"Latitude": "39.9087",
"Longitude": "116.3975",
"RecordTime": "2023-10-31T10:00:00",
"RecordTimeUTCStamp": "1698727200000",
"IsDeleted": "false",
"CreateTime": "2023-10-31T10:00:00",
"MessageType": "1",
"UserName": "张三",
"WeChatName": "张三的微信",
"PhoneNumber": "13800138000",
"AvatarUrl": "https://example.com/avatar.jpg"
}
]
}
```
**失败响应:**
```json
{
"success": false,
"message": "读取消息失败",
"error": "Redis操作错误"
}
```
## 3. 接口调用说明
### 3.1 HTTP客户端调用示例JavaScript
@@ -568,4 +763,4 @@ async function addConversation() {
- **最后更新时间**2023-11-01
- **维护人员**:系统管理员
- **版本号**v1.1.0
- **版本号**v1.2.0