# MessageTaskService
> 消息发送任务服务

---

## countMessageTasksWithStatus
> 计算某个状态的消息任务数量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/MessageTaskService/countMessageTasksWithStatus`
- RPC：`rpc countMessageTasksWithStatus(CountMessageTasksWithStatusRequest) returns (RPCCountResponse);`

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

```json
{}
```

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

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

**调用示例**

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

---

## createMessageTask
> 创建消息任务

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/MessageTaskService/createMessageTask`
- RPC：`rpc createMessageTask (CreateMessageTaskRequest) returns (CreateMessageTaskResponse);`

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

```json
{
  "messageRecipientId": "int64 // 接收人ID",
  "messageMediaInstanceId": "int64 // 媒介实例ID",
  "user": "string // 用户标识",
  "subject": "string // 标题",
  "body": "string // 内容",
  "isPrimary": "bool // 是否优先发送"
}
```

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

```json
{
  "messageTaskId": "int64 // 消息任务ID"
}
```

**调用示例**

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

---

## deleteMessageTask
> 删除消息任务

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/MessageTaskService/deleteMessageTask`
- RPC：`rpc deleteMessageTask (DeleteMessageTaskRequest) returns (RPCSuccess);`

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

```json
{
  "messageTaskId": "int64 // 消息任务ID"
}
```

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

```json
{}
```

**调用示例**

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

---

## findEnabledMessageTask
> 读取消息任务状态

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/MessageTaskService/findEnabledMessageTask`
- RPC：`rpc findEnabledMessageTask (FindEnabledMessageTaskRequest) returns (FindEnabledMessageTaskResponse);`

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

```json
{
  "messageTaskId": "int64 // 消息任务ID"
}
```

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

```json
{
  "messageTask": "MessageTask // 消息任务信息"
}
```

**调用示例**

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

---

## listMessageTasksWithStatus
> 根据状态列出某页任务

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/MessageTaskService/listMessageTasksWithStatus`
- RPC：`rpc listMessageTasksWithStatus(ListMessageTasksWithStatusRequest) returns (ListMessageTasksWithStatusResponse);`

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

```json
{}
```

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

```json
{
  "messageTasks": "[]MessageTask"
}
```

**调用示例**

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

---

## sendMessageTask
> 发送某个消息任务

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/MessageTaskService/sendMessageTask`
- RPC：`rpc sendMessageTask(SendMessageTaskRequest) returns (SendMessageTaskResponse);`

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

```json
{
  "messageMediaInstanceId": "int64 // 媒介实例ID",
  "user": "string // 用户标识",
  "subject": "string // 标题",
  "body": "string // 内容"
}
```

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

```json
{
  "isOk": "bool // 是否成功",
  "error": "string // 失败时的提示信息",
  "response": "string // 发送成功后响应内容"
}
```

**调用示例**

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

---

## updateMessageTaskStatus
> 修改消息任务状态

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/MessageTaskService/updateMessageTaskStatus`
- RPC：`rpc updateMessageTaskStatus(UpdateMessageTaskStatusRequest) returns (RPCSuccess);`

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

```json
{}
```

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

```json
{}
```

**调用示例**

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

---
