# AdminService
> 管理员服务

---

## checkAdminExists
> 检查管理员是否存在

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/checkAdminExists`
- RPC：`rpc checkAdminExists (CheckAdminExistsRequest) returns (CheckAdminExistsResponse);`

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

```json
{
  "adminId": "int64 // 管理员ID"
}
```

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

```json
{
  "isOk": "bool",
  "message": "string"
}
```

**调用示例**

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

---

## checkAdminOTPWithUsername
> 根据用户名检查是否需要输入OTP

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/checkAdminOTPWithUsername`
- RPC：`rpc checkAdminOTPWithUsername (CheckAdminOTPWithUsernameRequest) returns (CheckAdminOTPWithUsernameResponse);`

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

```json
{
  "username": "string"
}
```

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

```json
{
  "requireOTP": "bool"
}
```

**调用示例**

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

---

## checkAdminUsername
> 检查管理员用户名是否存在

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/checkAdminUsername`
- RPC：`rpc checkAdminUsername (CheckAdminUsernameRequest) returns (CheckAdminUsernameResponse);`

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

```json
{
  "adminId": "int64 // 管理员ID",
  "username": "string"
}
```

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

```json
{
  "exists": "bool"
}
```

**调用示例**

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

---

## composeAdminDashboard
> 取得管理员Dashboard数据

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/composeAdminDashboard`
- RPC：`rpc composeAdminDashboard (ComposeAdminDashboardRequest) returns (ComposeAdminDashboardResponse);`

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

```json
{
  "apiVersion": "string // 当前API版本号"
}
```

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

```json
{
  "countNodeClusters": "int64",
  "countNodes": "int64 // 节点数",
  "countOfflineNodes": "int64",
  "countServers": "int64",
  "countAuditingServers": "int64",
  "countUsers": "int64",
  "countAPINodes": "int64",
  "countOfflineAPINodes": "int64",
  "countDBNodes": "int64",
  "countOfflineDBNodes": "int64",
  "countUserNodes": "int64",
  "countOfflineUserNodes": "int64",
  "defaultNodeClusterId": "int64",
  "dailyTrafficStats": "[]DailyTrafficStat",
  "hourlyTrafficStats": "[]HourlyTrafficStat",
  "nodeUpgradeInfo": "UpgradeInfo",
  "apiNodeUpgradeInfo": "UpgradeInfo",
  "userNodeUpgradeInfo": "UpgradeInfo",
  "authorityNodeUpgradeInfo": "UpgradeInfo",
  "nsNodeUpgradeInfo": "UpgradeInfo",
  "reportNodeUpgradeInfo": "UpgradeInfo",
  "topNodeStats": "[]NodeStat",
  "topDomainStats": "[]DomainStat",
  "topCountryStats": "[]CountryStat",
  "metricDataCharts": "[]MetricDataChart",
  "day": "string // 日期 YYYYMMDD",
  "bytes": "int64",
  "cachedBytes": "int64",
  "countRequests": "int64",
  "countCachedRequests": "int64",
  "countAttackRequests": "int64",
  "attackBytes": "int64",
  "countIPs": "int64 // 独立IP数量",
  "hour": "string",
  "nodeId": "int64 // 节点ID",
  "nodeName": "string",
  "serverId": "int64 // 服务ID（网站ID）",
  "domain": "string",
  "countryName": "string",
  "percent": "float // 流量占比",
  "newVersion": "string // 新版本"
}
```

**调用示例**

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

---

## countAllEnabledAdmins
> 计算管理员数量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/countAllEnabledAdmins`
- RPC：`rpc countAllEnabledAdmins (CountAllEnabledAdminsRequest) returns (RPCCountResponse);`

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

```json
{
  "keyword": "string // 可选项，查询关键词",
  "hasWeakPassword": "bool // 可选项，筛选有弱密码的管理员，只有超级管理员才能查询"
}
```

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

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

**调用示例**

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

---

## createAdmin
> 创建管理员

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/createAdmin`
- RPC：`rpc createAdmin (CreateAdminRequest) returns (CreateAdminResponse);`

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

```json
{
  "username": "string",
  "password": "string",
  "fullname": "string",
  "modulesJSON": "bytes",
  "isSuper": "bool",
  "canLogin": "bool"
}
```

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

```json
{
  "adminId": "int64 // 管理员ID"
}
```

**调用示例**

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

---

## createOrUpdateAdmin
> 创建或修改管理员

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/createOrUpdateAdmin`
- RPC：`rpc createOrUpdateAdmin (CreateOrUpdateAdminRequest) returns (CreateOrUpdateAdminResponse);`

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

```json
{
  "username": "string",
  "password": "string"
}
```

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

```json
{
  "adminId": "int64 // 管理员ID"
}
```

**调用示例**

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

---

## deleteAdmin
> 删除管理员

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/deleteAdmin`
- RPC：`rpc deleteAdmin (DeleteAdminRequest) returns (RPCSuccess);`

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

```json
{
  "adminId": "int64 // 管理员ID"
}
```

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

```json
{}
```

**调用示例**

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

---

## findAdminFullname
> 获取管理员名称

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/findAdminFullname`
- RPC：`rpc findAdminFullname (FindAdminFullnameRequest) returns (FindAdminFullnameResponse);`

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

```json
{
  "adminId": "int64 // 管理员ID"
}
```

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

```json
{
  "fullname": "string"
}
```

**调用示例**

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

---

## findAdminWithUsername
> 使用用管理员户名查找管理员信息

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/findAdminWithUsername`
- RPC：`rpc findAdminWithUsername(FindAdminWithUsernameRequest) returns (FindAdminWithUsernameResponse);`

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

```json
{
  "username": "string // 管理员用户名"
}
```

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

```json
{
  "admin": "Admin // 管理员信息"
}
```

**调用示例**

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

---

## findAllAdminModules
> 获取所有管理员的权限列表

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/findAllAdminModules`
- RPC：`rpc findAllAdminModules (FindAllAdminModulesRequest) returns (FindAllAdminModulesResponse);`

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

```json
{}
```

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

```json
{
  "adminModules": "[]AdminModuleList"
}
```

**调用示例**

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

---

## findEnabledAdmin
> 获取管理员信息

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/findEnabledAdmin`
- RPC：`rpc findEnabledAdmin (FindEnabledAdminRequest) returns (FindEnabledAdminResponse);`

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

```json
{
  "adminId": "int64 // 管理员ID"
}
```

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

```json
{
  "admin": "Admin"
}
```

**调用示例**

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

---

## getUserLoginToken
> 获取用户登录令牌

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/getUserLoginToken`
- RPC：`rpc getUserLoginToken(getUserLoginTokenRequest) returns (getUserLoginTokenResponse);`

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

```json
{
  "userId": "int64 // 用户ID"
}
```

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

```json
{
  "token": "string"
}
```

**调用示例**

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

---

## listEnabledAdmins
> 列出单页的管理员

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/listEnabledAdmins`
- RPC：`rpc listEnabledAdmins (ListEnabledAdminsRequest) returns (ListEnabledAdminsResponse);`

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

```json
{
  "keyword": "string // 可选项，查询关键词",
  "hasWeakPassword": "bool // 可选项，筛选有弱密码的管理员，只有超级管理员才能查询",
  "offset": "int64 // 读取位置，从0开始",
  "size": "int64 // 读取数量"
}
```

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

```json
{
  "admins": "[]Admin"
}
```

**调用示例**

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

---

## updateAdmin
> 修改管理员

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/updateAdmin`
- RPC：`rpc updateAdmin (UpdateAdminRequest) returns (RPCSuccess);`

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

```json
{
  "adminId": "int64 // 管理员ID",
  "username": "string",
  "password": "string",
  "fullname": "string",
  "modulesJSON": "bytes",
  "isSuper": "bool",
  "isOn": "bool // 是否启用",
  "canLogin": "bool"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateAdminInfo
> 修改管理员信息

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/updateAdminInfo`
- RPC：`rpc updateAdminInfo (UpdateAdminInfoRequest) returns (RPCSuccess);`

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

```json
{
  "adminId": "int64 // 管理员ID",
  "fullname": "string"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateAdminLang
> 修改管理员使用的语言

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/updateAdminLang`
- RPC：`rpc updateAdminLang(UpdateAdminLangRequest) returns (RPCSuccess);`

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

```json
{
  "langCode": "string // 语言代号：en-us, zh-cn, ...，如果为空表示默认"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateAdminLogin
> 修改管理员登录信息

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/updateAdminLogin`
- RPC：`rpc updateAdminLogin (UpdateAdminLoginRequest) returns (RPCSuccess);`

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

```json
{
  "adminId": "int64 // 管理员ID",
  "username": "string",
  "password": "string"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateAdminTheme
> 修改管理员使用的界面风格

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/AdminService/updateAdminTheme`
- RPC：`rpc updateAdminTheme (UpdateAdminThemeRequest) returns (RPCSuccess);`

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

```json
{
  "adminId": "int64 // 管理员ID",
  "theme": "string // 风格代号"
}
```

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

```json
{}
```

**调用示例**

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

---
