# UserTrafficPackageService
> 用户流量包服务

---

## buyUserTrafficPackage
> 购买用户流量包

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserTrafficPackageService/buyUserTrafficPackage`
- RPC：`rpc buyUserTrafficPackage(BuyUserTrafficPackageRequest) returns (BuyUserTrafficPackageResponse);`

**请求对象 (`BuyUserTrafficPackageRequest`)**

```json
{
  "userId": "int64 // 用户ID",
  "trafficPackageId": "int64",
  "nodeRegionId": "int64",
  "trafficPackagePeriodId": "int64",
  "count": "int32 // 数量"
}
```

**响应对象 (`BuyUserTrafficPackageResponse`)**

```json
{
  "userTrafficPackageIds": "[]int64"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/UserTrafficPackageService/buyUserTrafficPackage" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## countUserTrafficPackages
> 查询当前流量包数量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserTrafficPackageService/countUserTrafficPackages`
- RPC：`rpc countUserTrafficPackages(CountUserTrafficPackagesRequest) returns (RPCCountResponse);`

**请求对象 (`CountUserTrafficPackagesRequest`)**

```json
{
  "trafficPackageId": "int64",
  "userId": "int64 // 用户ID",
  "nodeRegionId": "int64",
  "trafficPackagePeriodId": "int64",
  "expiresDay": "string",
  "availableOnly": "bool // 是否只查询有效的流量包"
}
```

**响应对象 (`RPCCountResponse`)**

```json
{
  "count": "int64 // 数量"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/UserTrafficPackageService/countUserTrafficPackages" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## createUserTrafficPackage
> 创建用户流量包

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserTrafficPackageService/createUserTrafficPackage`
- RPC：`rpc createUserTrafficPackage(CreateUserTrafficPackageRequest) returns (CreateUserTrafficPackageResponse);`

**请求对象 (`CreateUserTrafficPackageRequest`)**

```json
{
  "userId": "int64 // 用户ID",
  "trafficPackageId": "int64",
  "nodeRegionId": "int64",
  "trafficPackagePeriodId": "int64",
  "count": "int32 // 数量"
}
```

**响应对象 (`CreateUserTrafficPackageResponse`)**

```json
{
  "userTrafficPackageIds": "[]int64"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/UserTrafficPackageService/createUserTrafficPackage" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## deleteUserTrafficPackage
> 删除流量包

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserTrafficPackageService/deleteUserTrafficPackage`
- RPC：`rpc deleteUserTrafficPackage(DeleteUserTrafficPackageRequest) returns (RPCSuccess);`

**请求对象 (`DeleteUserTrafficPackageRequest`)**

```json
{
  "userTrafficPackageId": "int64"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/UserTrafficPackageService/deleteUserTrafficPackage" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## listUserTrafficPackages
> 列出单页流量包

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserTrafficPackageService/listUserTrafficPackages`
- RPC：`rpc listUserTrafficPackages(ListUserTrafficPackagesRequest) returns (ListUserTrafficPackagesResponse);`

**请求对象 (`ListUserTrafficPackagesRequest`)**

```json
{
  "trafficPackageId": "int64",
  "userId": "int64 // 用户ID",
  "nodeRegionId": "int64",
  "trafficPackagePeriodId": "int64",
  "expiresDay": "string",
  "availableOnly": "bool // 是否只查询有效的流量包",
  "offset": "int64 // 读取位置",
  "size": "int64 // 数量，通常不能小于0"
}
```

**响应对象 (`ListUserTrafficPackagesResponse`)**

```json
{
  "userTrafficPackages": "[]UserTrafficPackage"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/UserTrafficPackageService/listUserTrafficPackages" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---
