# ServerDailyStatService
> 服务统计相关服务

---

## findLatestServerDailyStats
> 读取最近N日的统计数据

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ServerDailyStatService/findLatestServerDailyStats`
- RPC：`rpc findLatestServerDailyStats (FindLatestServerDailyStatsRequest) returns (FindLatestServerDailyStatsResponse);`

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

```json
{
  "serverId": "int64 // 服务ID（网站ID）",
  "nodeRegionId": "int64 // 区域ID，可选",
  "days": "int32 // 天数"
}
```

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

```json
{
  "stats": "[]DailyStat",
  "day": "string",
  "bytes": "int64",
  "cachedBytes": "int64",
  "countRequests": "int64",
  "countCachedRequests": "int64"
}
```

**调用示例**

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

---

## findLatestServerHourlyStats
> 按小时读取统计数据

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ServerDailyStatService/findLatestServerHourlyStats`
- RPC：`rpc findLatestServerHourlyStats (FindLatestServerHourlyStatsRequest) returns (FindLatestServerHourlyStatsResponse);`

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

```json
{
  "serverId": "int64 // 服务ID（网站ID）",
  "hours": "int32 // 小时数"
}
```

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

```json
{
  "stats": "[]HourlyStat",
  "hour": "string",
  "bytes": "int64",
  "cachedBytes": "int64",
  "countRequests": "int64",
  "countCachedRequests": "int64"
}
```

**调用示例**

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

---

## findLatestServerMinutelyStats
> 按分钟读取统计数据，并返回秒级平均流量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ServerDailyStatService/findLatestServerMinutelyStats`
- RPC：`rpc findLatestServerMinutelyStats (FindLatestServerMinutelyStatsRequest) returns (FindLatestServerMinutelyStatsResponse);`

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

```json
{
  "serverId": "int64 // 服务ID（网站ID）",
  "minutes": "int32 // 分钟数"
}
```

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

```json
{
  "stats": "[]MinutelyStat",
  "minute": "string",
  "bytes": "int64",
  "cachedBytes": "int64",
  "countRequests": "int64",
  "countCachedRequests": "int64"
}
```

**调用示例**

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

---

## findServer5MinutelyStatsWithDay
> 读取某天的5分钟间隔流量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ServerDailyStatService/findServer5MinutelyStatsWithDay`
- RPC：`rpc findServer5MinutelyStatsWithDay(FindServer5MinutelyStatsWithDayRequest) returns (FindServer5MinutelyStatsWithDayResponse);`

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

```json
{
  "serverId": "int64 // 服务ID（网站ID）",
  "day": "string // 必需，格式：YYYYMMDD",
  "timeFrom": "string // 可选，开始时间，格式：HHIISS，比如 130000",
  "timeTo": "string // 可选，结束时间，格式：HHIISS，比如 130459"
}
```

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

```json
{
  "stats": "[]Stat",
  "day": "string",
  "timeFrom": "string",
  "timeTo": "string",
  "bytes": "int64",
  "cachedBytes": "int64",
  "countRequests": "int64",
  "countCachedRequests": "int64"
}
```

**调用示例**

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

---

## findServerDailyStatsBetweenDays
> 读取日期段内的流量数据

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/ServerDailyStatService/findServerDailyStatsBetweenDays`
- RPC：`rpc findServerDailyStatsBetweenDays (FindServerDailyStatsBetweenDaysRequest) returns (FindServerDailyStatsBetweenDaysResponse);`

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

```json
{
  "userId": "int64 // 用户ID，和服务ID二选一",
  "serverId": "int64 // 服务ID，和用户ID二选一",
  "dayFrom": "string // 开始日期 YYYYMMDD",
  "dayTo": "string // 结束日期 YYYYMMDD",
  "nodeRegionId": "int64 // 区域ID"
}
```

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

```json
{
  "stats": "[]Stat",
  "day": "string",
  "timeFrom": "string",
  "timeTo": "string",
  "timeAt": "string",
  "bytes": "int64",
  "cachedBytes": "int64",
  "countRequests": "int64",
  "countCachedRequests": "int64"
}
```

**调用示例**

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

---

## sumCurrentServerDailyStats
> 查找单个服务当前时刻（N分钟内）统计数据

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/ServerDailyStatService/sumCurrentServerDailyStats`
- RPC：`rpc sumCurrentServerDailyStats(SumCurrentServerDailyStatsRequest) returns (SumCurrentServerDailyStatsResponse);`

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

```json
{
  "serverId": "int64 // 服务ID（网站ID）"
}
```

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

```json
{
  "serverDailyStat": "ServerDailyStat"
}
```

**调用示例**

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

---

## sumServerDailyStats
> 计算单个服务的日统计

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/ServerDailyStatService/sumServerDailyStats`
- RPC：`rpc sumServerDailyStats(SumServerDailyStatsRequest) returns (SumServerDailyStatsResponse);`

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

```json
{
  "userId": "int64 // 用户ID",
  "serverId": "int64 // 服务ID（网站ID）",
  "nodeRegionId": "int64",
  "day": "string // YYYYMMDD",
  "dayFrom": "string // day 和 dayFrom+dayTo 二选一， YYYYMMDD",
  "dayTo": "string // day 和 dayFrom+dayTo 二选一，YYYYMMDD"
}
```

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

```json
{
  "serverDailyStat": "ServerDailyStat"
}
```

**调用示例**

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

---

## sumServerMonthlyStats
> 计算单个服务的月统计

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/ServerDailyStatService/sumServerMonthlyStats`
- RPC：`rpc sumServerMonthlyStats(SumServerMonthlyStatsRequest) returns (SumServerMonthlyStatsResponse);`

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

```json
{
  "serverId": "int64 // 服务ID（网站ID）",
  "month": "string // YYYYMM"
}
```

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

```json
{
  "serverMonthlyStat": "ServerDailyStat"
}
```

**调用示例**

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

---
