# MessageService
> 消息相关服务

---

## countUnreadMessages
> 计算未读消息数

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/MessageService/countUnreadMessages`
- RPC：`rpc countUnreadMessages (CountUnreadMessagesRequest) returns (RPCCountResponse);`

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

```json
{}
```

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

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

**调用示例**

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

---

## listUnreadMessages
> 列出单页未读消息

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/MessageService/listUnreadMessages`
- RPC：`rpc listUnreadMessages (ListUnreadMessagesRequest) returns (ListUnreadMessagesResponse);`

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

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

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

```json
{
  "messages": "[]Message"
}
```

**调用示例**

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

---

## updateAllMessagesRead
> 设置所有消息为已读

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/MessageService/updateAllMessagesRead`
- RPC：`rpc updateAllMessagesRead (UpdateAllMessagesReadRequest) returns (RPCSuccess);`

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

```json
{}
```

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

```json
{}
```

**调用示例**

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

---

## updateMessageRead
> 设置消息已读状态

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/MessageService/updateMessageRead`
- RPC：`rpc updateMessageRead (UpdateMessageReadRequest) returns (RPCSuccess);`

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

```json
{
  "messageId": "int64",
  "isRead": "bool"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateMessagesRead
> 设置一组消息已读状态

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/MessageService/updateMessagesRead`
- RPC：`rpc updateMessagesRead (UpdateMessagesReadRequest) returns (RPCSuccess);`

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

```json
{
  "messageIds": "[]int64",
  "isRead": "bool"
}
```

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

```json
{}
```

**调用示例**

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

---
