# DBNodeService
> 数据库节点服务

---

## checkDBNodeStatus
> 检查数据库节点状态

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/DBNodeService/checkDBNodeStatus`
- RPC：`rpc checkDBNodeStatus(CheckDBNodeStatusRequest) returns (CheckDBNodeStatusResponse);`

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

```json
{
  "dbNodeId": "int64"
}
```

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

```json
{
  "dbNodeStatus": "DBNodeStatus"
}
```

**调用示例**

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

---

## countAllEnabledDBNodes
> 计算可用的数据库节点数量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/DBNodeService/countAllEnabledDBNodes`
- RPC：`rpc countAllEnabledDBNodes (CountAllEnabledDBNodesRequest) returns (RPCCountResponse);`

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

```json
{}
```

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

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

**调用示例**

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

---

## createDBNode
> 创建数据库节点

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/DBNodeService/createDBNode`
- RPC：`rpc createDBNode (CreateDBNodeRequest) returns (CreateDBNodeResponse);`

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

```json
{
  "isOn": "bool // 是否启用",
  "name": "string // 名称",
  "description": "string // 描述（备注）",
  "host": "string",
  "port": "int32",
  "database": "string",
  "username": "string",
  "password": "string",
  "charset": "string",
  "dbEngine": "string"
}
```

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

```json
{
  "dbNodeId": "int64"
}
```

**调用示例**

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

---

## deleteDBNode
> 删除节点

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/DBNodeService/deleteDBNode`
- RPC：`rpc deleteDBNode (DeleteDBNodeRequest) returns (RPCSuccess);`

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

```json
{
  "dbNodeId": "int64"
}
```

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

```json
{}
```

**调用示例**

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

---

## deleteDBNodeTable
> 删除表

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/DBNodeService/deleteDBNodeTable`
- RPC：`rpc deleteDBNodeTable (DeleteDBNodeTableRequest) returns (RPCSuccess);`

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

```json
{
  "dbNodeId": "int64",
  "dbNodeTable": "string"
}
```

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

```json
{}
```

**调用示例**

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

---

## findAllDBNodeTables
> 获取所有表信息

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/DBNodeService/findAllDBNodeTables`
- RPC：`rpc findAllDBNodeTables (FindAllDBNodeTablesRequest) returns (FindAllDBNodeTablesResponse);`

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

```json
{
  "dbNodeId": "int64"
}
```

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

```json
{
  "dbNodeTables": "[]DBTable"
}
```

**调用示例**

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

---

## findEnabledDBNode
> 根据ID查找可用的数据库节点

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/DBNodeService/findEnabledDBNode`
- RPC：`rpc findEnabledDBNode (FindEnabledDBNodeRequest) returns (FindEnabledDBNodeResponse);`

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

```json
{
  "dbNodeId": "int64"
}
```

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

```json
{
  "dbNode": "DBNode"
}
```

**调用示例**

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

---

## listEnabledDBNodes
> 列出单页的数据库节点

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/DBNodeService/listEnabledDBNodes`
- RPC：`rpc listEnabledDBNodes (ListEnabledDBNodesRequest) returns (ListEnabledDBNodesResponse);`

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

```json
{
  "offset": "int64 // 读取位置",
  "size": "int64 // 数量，通常不能小于0"
}
```

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

```json
{
  "dbNodes": "[]DBNode"
}
```

**调用示例**

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

---

## truncateDBNodeTable
> 清空表

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/DBNodeService/truncateDBNodeTable`
- RPC：`rpc truncateDBNodeTable (TruncateDBNodeTableRequest) returns (RPCSuccess);`

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

```json
{
  "dbNodeId": "int64",
  "dbNodeTable": "string"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateDBNode
> 修改数据库节点

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/DBNodeService/updateDBNode`
- RPC：`rpc updateDBNode (UpdateDBNodeRequest) returns (RPCSuccess);`

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

```json
{
  "dbNodeId": "int64",
  "name": "string // 名称",
  "description": "string // 描述（备注）",
  "isOn": "bool // 是否启用",
  "host": "string",
  "port": "int32",
  "database": "string",
  "username": "string",
  "password": "string",
  "charset": "string",
  "dbEngine": "string"
}
```

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

```json
{}
```

**调用示例**

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

---
