# 二手委托人信息管理接口测试文档

## 接口列表

### 1. 创建委托人信息
**接口地址**: `POST /secondEntrustUser/create`

**请求参数**:
```json
{
  "entrustTradeId": 1,
  "entrustTradeNo": "TRADE202511210001",
  "entrustUserPhone": "13800138000",
  "entrustUserName": "张三",
  "entrustIdCard": "110101199001011234",
  "entrustIdCardImg": "https://example.com/id_card.jpg"
}
```

**响应示例**:
```json
{
  "code": 200,
  "msg": "创建成功",
  "data": true
}
```

---

### 2. 根据交易ID获取委托人信息
**接口地址**: `GET /secondEntrustUser/getByTradeId?entrustTradeId=1`

**响应示例**:
```json
{
  "code": 200,
  "msg": "操作成功",
  "data": {
    "id": 1,
    "entrustTradeId": 1,
    "entrustTradeNo": "TRADE202511210001",
    "entrustUserPhone": "13800138000",
    "entrustUserName": "张三",
    "entrustIdCard": "110101199001011234",
    "entrustIdCardImg": "https://example.com/id_card.jpg",
    "deleteFlag": 0,
    "createdTime": "2025-11-21 10:00:00",
    "createdUserId": 1,
    "updatedTime": "2025-11-21 10:00:00",
    "updatedUserId": 1
  }
}
```

---

### 3. 根据交易编号获取委托人信息
**接口地址**: `GET /secondEntrustUser/getByTradeNo?entrustTradeNo=TRADE202511210001`

**响应示例**: 同上

---

### 4. 根据ID获取委托人信息
**接口地址**: `GET /secondEntrustUser/getById?id=1`

**响应示例**: 同上

---

### 5. 更新委托人信息
**接口地址**: `PUT /secondEntrustUser/update/1`

**请求参数**:
```json
{
  "entrustTradeId": 1,
  "entrustTradeNo": "TRADE202511210001",
  "entrustUserPhone": "13800138001",
  "entrustUserName": "李四",
  "entrustIdCard": "110101199001011235",
  "entrustIdCardImg": "https://example.com/id_card2.jpg"
}
```

**响应示例**:
```json
{
  "code": 200,
  "msg": "更新成功",
  "data": true
}
```

---

### 6. 删除委托人信息
**接口地址**: `DELETE /secondEntrustUser/delete?id=1`

**响应示例**:
```json
{
  "code": 200,
  "msg": "删除成功",
  "data": true
}
```

---

### 7. 根据用户电话查询委托人信息列表
**接口地址**: `GET /secondEntrustUser/getByUserPhone?entrustUserPhone=13800138000`

**响应示例**:
```json
{
  "code": 200,
  "msg": "操作成功",
  "data": [
    {
      "id": 1,
      "entrustTradeId": 1,
      "entrustTradeNo": "TRADE202511210001",
      "entrustUserPhone": "13800138000",
      "entrustUserName": "张三",
      "entrustIdCard": "110101199001011234",
      "entrustIdCardImg": "https://example.com/id_card.jpg",
      "deleteFlag": 0,
      "createdTime": "2025-11-21 10:00:00",
      "createdUserId": 1,
      "updatedTime": "2025-11-21 10:00:00",
      "updatedUserId": 1
    }
  ]
}
```

---

## Postman 测试步骤

1. **创建委托人信息**
   - Method: POST
   - URL: http://localhost:端口/secondEntrustUser/create
   - Body (raw JSON):
   ```json
   {
     "entrustTradeId": 1,
     "entrustTradeNo": "TRADE202511210001",
     "entrustUserPhone": "13800138000",
     "entrustUserName": "张三",
     "entrustIdCard": "110101199001011234",
     "entrustIdCardImg": "https://example.com/id_card.jpg"
   }
   ```

2. **根据交易ID查询委托人信息**
   - Method: GET
   - URL: http://localhost:端口/secondEntrustUser/getByTradeId?entrustTradeId=1

3. **根据交易编号查询委托人信息**
   - Method: GET
   - URL: http://localhost:端口/secondEntrustUser/getByTradeNo?entrustTradeNo=TRADE202511210001

4. **更新委托人信息**
   - Method: PUT
   - URL: http://localhost:端口/secondEntrustUser/update/1
   - Body (raw JSON):
   ```json
   {
     "entrustTradeId": 1,
     "entrustTradeNo": "TRADE202511210001",
     "entrustUserPhone": "13800138001",
     "entrustUserName": "李四"
   }
   ```

5. **删除委托人信息**
   - Method: DELETE
   - URL: http://localhost:端口/secondEntrustUser/delete?id=1

---

## 测试数据 SQL

```sql
-- 插入测试数据
INSERT INTO second_entrust_user (entrust_trade_id, entrust_trade_no, entrust_user_phone, entrust_user_name, entrust_id_card, entrust_id_card_img, delete_flag, created_time, created_user_id, updated_time, updated_user_id)
VALUES (1, 'TRADE202511210001', '13800138000', '张三', '110101199001011234', 'https://example.com/id_card.jpg', 0, NOW(), 1, NOW(), 1);

-- 查询数据
SELECT * FROM second_entrust_user WHERE delete_flag = 0;

-- 根据交易ID查询
SELECT * FROM second_entrust_user WHERE entrust_trade_id = 1 AND delete_flag = 0;

-- 根据交易编号查询
SELECT * FROM second_entrust_user WHERE entrust_trade_no = 'TRADE202511210001' AND delete_flag = 0;

-- 根据用户电话查询
SELECT * FROM second_entrust_user WHERE entrust_user_phone = '13800138000' AND delete_flag = 0;
```

