# UserService
> 用户相关服务

---

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

- 角色：`user`
- HTTP：`POST https://backend.dooki.cloud/UserService/checkUserOTPWithUsername`
- RPC：`rpc checkUserOTPWithUsername (CheckUserOTPWithUsernameRequest) returns (CheckUserOTPWithUsernameResponse);`

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

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

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

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

**调用示例**

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

---

## checkUserUsername
> 检查用户名是否存在

- 角色：`user`, `admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/checkUserUsername`
- RPC：`rpc checkUserUsername (CheckUserUsernameRequest) returns (CheckUserUsernameResponse);`

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

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

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

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

**调用示例**

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

---

## composeUserDashboard
> 取得用户Dashboard数据

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/UserService/composeUserDashboard`
- RPC：`rpc composeUserDashboard (ComposeUserDashboardRequest) returns (ComposeUserDashboardResponse);`

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

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

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

```json
{
  "countServers": "int64",
  "monthlyTrafficBytes": "int64",
  "monthlyPeekBandwidthBytes": "int64",
  "dailyTrafficBytes": "int64",
  "dailyPeekBandwidthBytes": "int64",
  "dailyTrafficStats": "[]DailyTrafficStat",
  "dailyPeekBandwidthStats": "[]DailyPeekBandwidthStat",
  "bandwidthPercentile": "int32 // 带宽百分位",
  "bandwidthPercentileBits": "int64 // 带宽百分位上的比特数",
  "day": "string",
  "bytes": "int64",
  "cachedBytes": "int64",
  "attackBytes": "int64",
  "countRequests": "int64",
  "countCachedRequests": "int64",
  "countAttackRequests": "int64"
}
```

**调用示例**

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

---

## composeUserGlobalBoard
> 组合全局的看板数据

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/composeUserGlobalBoard`
- RPC：`rpc composeUserGlobalBoard (ComposeUserGlobalBoardRequest) returns (ComposeUserGlobalBoardResponse);`

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

```json
{}
```

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

```json
{
  "totalUsers": "int64",
  "countTodayUsers": "int64",
  "countWeeklyUsers": "int64",
  "countUserNodes": "int64",
  "countOfflineUserNodes": "int64",
  "countVerifyingUsers": "int64",
  "dailyStats": "[]DailyStat",
  "cpuNodeValues": "[]NodeValue",
  "memoryNodeValues": "[]NodeValue",
  "loadNodeValues": "[]NodeValue",
  "topTrafficStats": "[]TrafficStat",
  "day": "string",
  "count": "int64 // 数量",
  "userId": "int64 // 用户ID",
  "userName": "string",
  "countRequests": "int64",
  "bytes": "int64"
}
```

**调用示例**

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

---

## countAllEnabledUsers
> 计算用户数量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/countAllEnabledUsers`
- RPC：`rpc countAllEnabledUsers (CountAllEnabledUsersRequest) returns (RPCCountResponse);`

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

```json
{
  "keyword": "string // 关键词",
  "isVerifying": "bool",
  "mobileIsVerified": "int32 // 手机号是否已验证，1表示已验证，0表示未验证，-1表示所有状态"
}
```

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

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

**调用示例**

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

---

## createUser
> 创建用户

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/createUser`
- RPC：`rpc createUser (CreateUserRequest) returns (CreateUserResponse);`

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

```json
{
  "username": "string",
  "password": "string",
  "fullname": "string",
  "mobile": "string",
  "tel": "string",
  "email": "string",
  "remark": "string",
  "source": "string",
  "nodeClusterId": "int64 // 集群ID"
}
```

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

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

**调用示例**

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

---

## deleteUser
> 删除用户

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/deleteUser`
- RPC：`rpc deleteUser (DeleteUserRequest) returns (RPCSuccess);`

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

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

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

```json
{}
```

**调用示例**

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

---

## findAllUserFeatureDefinitions
> 获取所有的功能定义

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/findAllUserFeatureDefinitions`
- RPC：`rpc findAllUserFeatureDefinitions (FindAllUserFeatureDefinitionsRequest) returns (FindAllUserFeatureDefinitionsResponse);`

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

```json
{}
```

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

```json
{
  "features": "[]UserFeature"
}
```

**调用示例**

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

---

## findEnabledUser
> 查询单个用户信息

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/findEnabledUser`
- RPC：`rpc findEnabledUser (FindEnabledUserRequest) returns (FindEnabledUserResponse);`

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

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

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

```json
{
  "user": "User"
}
```

**调用示例**

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

---

## findUserFeatures
> 获取用户所有的功能列表

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/findUserFeatures`
- RPC：`rpc findUserFeatures (FindUserFeaturesRequest) returns (FindUserFeaturesResponse);`

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

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

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

```json
{
  "features": "[]UserFeature"
}
```

**调用示例**

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

---

## findUserNodeClusterId
> 获取用户所在的集群ID

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/findUserNodeClusterId`
- RPC：`rpc findUserNodeClusterId (FindUserNodeClusterIdRequest) returns (FindUserNodeClusterIdResponse);`

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

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

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

```json
{
  "nodeClusterId": "int64 // 集群ID"
}
```

**调用示例**

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

---

## findUserPriceInfo
> 读取用户计费信息

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/findUserPriceInfo`
- RPC：`rpc findUserPriceInfo(FindUserPriceInfoRequest) returns (FindUserPriceInfoResponse);`

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

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

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

```json
{
  "priceType": "string",
  "pricePeriod": "string"
}
```

**调用示例**

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

---

## listEnabledUsers
> 列出单页用户

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/listEnabledUsers`
- RPC：`rpc listEnabledUsers (ListEnabledUsersRequest) returns (ListEnabledUsersResponse);`

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

```json
{
  "keyword": "string // 关键词",
  "isVerifying": "bool",
  "mobileIsVerified": "int32 // 手机号是否已验证，1表示已验证，0表示未验证，-1表示所有状态",
  "offset": "int64 // 读取位置",
  "size": "int64 // 数量，通常不能小于0"
}
```

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

```json
{
  "users": "[]User"
}
```

**调用示例**

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

---

## loginUser
> 登录

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/loginUser`
- RPC：`rpc loginUser (LoginUserRequest) returns (LoginUserResponse);`

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

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

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

```json
{
  "userId": "int64 // 用户ID",
  "isOk": "bool",
  "message": "string"
}
```

**调用示例**

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

---

## registerUser
> 注册用户

- 角色：`user`
- HTTP：`POST https://backend.dooki.cloud/UserService/registerUser`
- RPC：`rpc registerUser(RegisterUserRequest) returns (RegisterUserResponse);`

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

```json
{
  "username": "string",
  "password": "string",
  "mobile": "string",
  "email": "string",
  "fullname": "string",
  "ip": "string",
  "source": "string"
}
```

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

```json
{
  "userId": "int64 // 用户ID",
  "requireEmailVerification": "bool // 是否需要激活邮件"
}
```

**调用示例**

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

---

## renewUserServersState
> 更新用户服务可用状态

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/renewUserServersState`
- RPC：`rpc renewUserServersState(RenewUserServersStateRequest) returns (RenewUserServersStateResponse);`

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

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

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

```json
{
  "isEnabled": "bool"
}
```

**调用示例**

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

---

## updateAllUsersFeatures
> 设置所有用户能使用的功能

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/updateAllUsersFeatures`
- RPC：`rpc updateAllUsersFeatures(UpdateAllUsersFeaturesRequest) returns (RPCSuccess);`

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

```json
{
  "featureCodes": "[]string",
  "overwrite": "bool"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateUser
> 修改用户

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/updateUser`
- RPC：`rpc updateUser (UpdateUserRequest) returns (RPCSuccess);`

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

```json
{
  "userId": "int64 // 用户ID",
  "username": "string",
  "password": "string",
  "fullname": "string",
  "mobile": "string",
  "tel": "string",
  "email": "string",
  "remark": "string",
  "isOn": "bool // 是否启用",
  "nodeClusterId": "int64 // 集群ID",
  "bandwidthAlgo": "string"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateUserFeatures
> 设置单个用户能使用的功能

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/updateUserFeatures`
- RPC：`rpc updateUserFeatures (UpdateUserFeaturesRequest) returns (RPCSuccess);`

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

```json
{
  "userId": "int64 // 用户ID",
  "featureCodes": "[]string"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateUserInfo
> 修改用户基本信息

- 角色：`user`
- HTTP：`POST https://backend.dooki.cloud/UserService/updateUserInfo`
- RPC：`rpc updateUserInfo (UpdateUserInfoRequest) returns (RPCSuccess);`

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

```json
{
  "userId": "int64 // 用户ID",
  "fullname": "string",
  "mobile": "string",
  "email": "string"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateUserLogin
> 修改用户登录信息

- 角色：`user`
- HTTP：`POST https://backend.dooki.cloud/UserService/updateUserLogin`
- RPC：`rpc updateUserLogin (UpdateUserLoginRequest) returns (RPCSuccess);`

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

```json
{
  "userId": "int64 // 用户ID",
  "username": "string",
  "password": "string"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateUserPricePeriod
> 修改用户计费周期

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/updateUserPricePeriod`
- RPC：`rpc updateUserPricePeriod(UpdateUserPricePeriodRequest) returns (RPCSuccess);`

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

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

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

```json
{}
```

**调用示例**

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

---

## updateUserPriceType
> 修改用户计费方式

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/updateUserPriceType`
- RPC：`rpc updateUserPriceType(UpdateUserPriceTypeRequest) returns (RPCSuccess);`

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

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

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

```json
{}
```

**调用示例**

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

---

## verifyUser
> 审核用户

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/UserService/verifyUser`
- RPC：`rpc verifyUser(VerifyUserRequest) returns (RPCSuccess);`

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

```json
{
  "userId": "int64 // 用户ID",
  "isRejected": "bool",
  "rejectReason": "string"
}
```

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

```json
{}
```

**调用示例**

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

---
