Files
full/wiki/api/13-feed.md

454 lines
9.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# FEED API
动态发布、标签、时间线和动态设置。
> 本文档由 protobuf descriptor 生成。字段名采用 protobuf JSON 名称64 位整数在 JSON 中应按字符串处理。
## 接入方式
- 动态 HTTP`POST /rpc/feed/{Service}/{Method}`
- 原生 gRPC`/feed.{Service}/{Method}`
- grpc-gateway`POST /feed.{Service}/{Method}`
- 鉴权:需要登录的接口通过 `Authorization: <JWT>` 传递裸 JWT不添加 `Bearer` 前缀。
- 动态 HTTP 成功或失败均返回 HTTP 200业务状态见 `code``message``details`
## 服务概览
| 服务 | 方法数 | 说明 |
|---|---:|---|
| `Post` | 8 | Post 服务 |
| `Setting` | 2 | Setting 服务 |
| `Tag` | 3 | Tag 服务 |
| `Timeline` | 4 | Timeline 服务 |
## Post
| 方法 | 动态 HTTP 路径 | 请求 | 响应 | 类型 |
|---|---|---|---|---|
| `Fetch` | `POST /rpc/feed/Post/Fetch` | [`blocks.FetchRequest`](#blocksfetchrequest) | [`blocks.FeedPostListReply`](#blocksfeedpostlistreply) | Unary |
| `Create` | `POST /rpc/feed/Post/Create` | [`blocks.FeedPostItem`](#blocksfeedpostitem) | [`blocks.DataStatusReply`](#blocksdatastatusreply) | Unary |
| `Change` | `POST /rpc/feed/Post/Change` | [`blocks.FeedPostItem`](#blocksfeedpostitem) | [`blocks.DataStatusReply`](#blocksdatastatusreply) | Unary |
| `Remove` | `POST /rpc/feed/Post/Remove` | [`blocks.IdentRequest`](#blocksidentrequest) | [`blocks.DataStatusReply`](#blocksdatastatusreply) | Unary |
| `CommentList` | `POST /rpc/feed/Post/CommentList` | [`blocks.FetchRequest`](#blocksfetchrequest) | [`feed.CommentListReply`](#feedcommentlistreply) | Unary |
| `AddComment` | `POST /rpc/feed/Post/AddComment` | [`feed.CommentItem`](#feedcommentitem) | [`blocks.DataStatusReply`](#blocksdatastatusreply) | Unary |
| `DeleteComment` | `POST /rpc/feed/Post/DeleteComment` | [`blocks.IdentRequest`](#blocksidentrequest) | [`blocks.DataStatusReply`](#blocksdatastatusreply) | Unary |
| `Action` | `POST /rpc/feed/Post/Action` | [`feed.PostActionRequest`](#feedpostactionrequest) | [`blocks.DataStatusReply`](#blocksdatastatusreply) | Unary |
### Post.Fetch
- 动态 HTTP`POST /rpc/feed/Post/Fetch`
- gRPC`/feed.Post/Fetch`
- 请求示例:
```json
{
"page_no": "0",
"page_size": "0",
"params": {
"key": "string"
}
}
```
### Post.Create
- 动态 HTTP`POST /rpc/feed/Post/Create`
- gRPC`/feed.Post/Create`
- 请求示例:
```json
{
"attachs": [
{
"attachType": "string",
"identity": "string",
"url": "string"
}
],
"cntComment": "0",
"cntLike": "0",
"cntUnlike": "0",
"content": "string",
"feedId": "0",
"feedIdentity": "string",
"identity": "string",
"isOpen": false,
"tags": [
{
"content": "string",
"key": "string"
}
]
}
```
### Post.Change
- 动态 HTTP`POST /rpc/feed/Post/Change`
- gRPC`/feed.Post/Change`
- 请求示例:
```json
{
"attachs": [
{
"attachType": "string",
"identity": "string",
"url": "string"
}
],
"cntComment": "0",
"cntLike": "0",
"cntUnlike": "0",
"content": "string",
"feedId": "0",
"feedIdentity": "string",
"identity": "string",
"isOpen": false,
"tags": [
{
"content": "string",
"key": "string"
}
]
}
```
### Post.Remove
- 动态 HTTP`POST /rpc/feed/Post/Remove`
- gRPC`/feed.Post/Remove`
- 请求示例:
```json
{
"id": "0",
"identity": "string"
}
```
### Post.CommentList
- 动态 HTTP`POST /rpc/feed/Post/CommentList`
- gRPC`/feed.Post/CommentList`
- 请求示例:
```json
{
"page_no": "0",
"page_size": "0",
"params": {
"key": "string"
}
}
```
### Post.AddComment
- 动态 HTTP`POST /rpc/feed/Post/AddComment`
- gRPC`/feed.Post/AddComment`
- 请求示例:
```json
{
"content": "string",
"feedIdentity": "string",
"identity": "string",
"postIdentity": "string",
"subComment": [
{}
]
}
```
### Post.DeleteComment
- 动态 HTTP`POST /rpc/feed/Post/DeleteComment`
- gRPC`/feed.Post/DeleteComment`
- 请求示例:
```json
{
"id": "0",
"identity": "string"
}
```
### Post.Action
- 动态 HTTP`POST /rpc/feed/Post/Action`
- gRPC`/feed.Post/Action`
- 请求示例:
```json
{
"actionOp": "string",
"actionType": "string",
"identity": "string"
}
```
## Setting
| 方法 | 动态 HTTP 路径 | 请求 | 响应 | 类型 |
|---|---|---|---|---|
| `Info` | `POST /rpc/feed/Setting/Info` | [`blocks.Empty`](#blocksempty) | [`blocks.Empty`](#blocksempty) | Unary |
| `Rights` | `POST /rpc/feed/Setting/Rights` | [`blocks.Empty`](#blocksempty) | [`blocks.Empty`](#blocksempty) | Unary |
### Setting.Info
- 动态 HTTP`POST /rpc/feed/Setting/Info`
- gRPC`/feed.Setting/Info`
- 请求示例:
```json
{}
```
### Setting.Rights
- 动态 HTTP`POST /rpc/feed/Setting/Rights`
- gRPC`/feed.Setting/Rights`
- 请求示例:
```json
{}
```
## Tag
| 方法 | 动态 HTTP 路径 | 请求 | 响应 | 类型 |
|---|---|---|---|---|
| `List` | `POST /rpc/feed/Tag/List` | [`blocks.FetchRequest`](#blocksfetchrequest) | [`feed.TagListReply`](#feedtaglistreply) | Unary |
| `Create` | `POST /rpc/feed/Tag/Create` | [`feed.AddTagRequest`](#feedaddtagrequest) | [`blocks.DataStatusReply`](#blocksdatastatusreply) | Unary |
| `PostList` | `POST /rpc/feed/Tag/PostList` | [`blocks.FetchRequest`](#blocksfetchrequest) | [`blocks.FeedPostListReply`](#blocksfeedpostlistreply) | Unary |
### Tag.List
- 动态 HTTP`POST /rpc/feed/Tag/List`
- gRPC`/feed.Tag/List`
- 请求示例:
```json
{
"page_no": "0",
"page_size": "0",
"params": {
"key": "string"
}
}
```
### Tag.Create
- 动态 HTTP`POST /rpc/feed/Tag/Create`
- gRPC`/feed.Tag/Create`
- 请求示例:
```json
{
"tags": [
"string"
]
}
```
### Tag.PostList
- 动态 HTTP`POST /rpc/feed/Tag/PostList`
- gRPC`/feed.Tag/PostList`
- 请求示例:
```json
{
"page_no": "0",
"page_size": "0",
"params": {
"key": "string"
}
}
```
## Timeline
| 方法 | 动态 HTTP 路径 | 请求 | 响应 | 类型 |
|---|---|---|---|---|
| `Recommend` | `POST /rpc/feed/Timeline/Recommend` | [`blocks.FetchRequest`](#blocksfetchrequest) | [`blocks.FeedPostListReply`](#blocksfeedpostlistreply) | Unary |
| `Friend` | `POST /rpc/feed/Timeline/Friend` | [`blocks.FetchRequest`](#blocksfetchrequest) | [`blocks.FeedPostListReply`](#blocksfeedpostlistreply) | Unary |
| `Follow` | `POST /rpc/feed/Timeline/Follow` | [`blocks.FetchRequest`](#blocksfetchrequest) | [`blocks.FeedPostListReply`](#blocksfeedpostlistreply) | Unary |
| `Hot` | `POST /rpc/feed/Timeline/Hot` | [`blocks.FetchRequest`](#blocksfetchrequest) | [`blocks.FeedPostListReply`](#blocksfeedpostlistreply) | Unary |
### Timeline.Recommend
- 动态 HTTP`POST /rpc/feed/Timeline/Recommend`
- gRPC`/feed.Timeline/Recommend`
- 请求示例:
```json
{
"page_no": "0",
"page_size": "0",
"params": {
"key": "string"
}
}
```
### Timeline.Friend
- 动态 HTTP`POST /rpc/feed/Timeline/Friend`
- gRPC`/feed.Timeline/Friend`
- 请求示例:
```json
{
"page_no": "0",
"page_size": "0",
"params": {
"key": "string"
}
}
```
### Timeline.Follow
- 动态 HTTP`POST /rpc/feed/Timeline/Follow`
- gRPC`/feed.Timeline/Follow`
- 请求示例:
```json
{
"page_no": "0",
"page_size": "0",
"params": {
"key": "string"
}
}
```
### Timeline.Hot
- 动态 HTTP`POST /rpc/feed/Timeline/Hot`
- gRPC`/feed.Timeline/Hot`
- 请求示例:
```json
{
"page_no": "0",
"page_size": "0",
"params": {
"key": "string"
}
}
```
## 消息结构
### blocks.DataStatusReply
| JSON 字段 | 类型 | 规则 |
|---|---|---|
| `data` | `string` | 可选 |
| `timeseq` | `int64` | 可选 |
### blocks.Empty
空消息:请求时发送 `{}`
### blocks.FeedAttachItem
| JSON 字段 | 类型 | 规则 |
|---|---|---|
| `identity` | `string` | 可选 |
| `attachType` | `string` | 可选 |
| `url` | `string` | 可选 |
### blocks.FeedPostItem
| JSON 字段 | 类型 | 规则 |
|---|---|---|
| `identity` | `string` | 可选 |
| `content` | `string` | 可选 |
| `feedId` | `int64` | 可选 |
| `feedIdentity` | `string` | 可选 |
| `isOpen` | `bool` | 可选 |
| `cntUnlike` | `int64` | 可选 |
| `cntComment` | `int64` | 可选 |
| `cntLike` | `int64` | 可选 |
| `attachs` | `[]blocks.FeedAttachItem` | 数组 |
| `tags` | `[]blocks.FeedTagItem` | 数组 |
### blocks.FeedPostListReply
| JSON 字段 | 类型 | 规则 |
|---|---|---|
| `list` | `[]blocks.FeedPostItem` | 数组 |
| `cnt` | `int64` | 可选 |
### blocks.FeedTagItem
| JSON 字段 | 类型 | 规则 |
|---|---|---|
| `key` | `string` | 可选 |
| `content` | `string` | 可选 |
### blocks.FetchRequest
| JSON 字段 | 类型 | 规则 |
|---|---|---|
| `page_no` | `int64` | 可选 |
| `page_size` | `int64` | 可选 |
| `params` | `map<string, string>` | 对象映射 |
### blocks.FetchRequest.ParamsEntry
| JSON 字段 | 类型 | 规则 |
|---|---|---|
| `key` | `string` | 可选 |
| `value` | `string` | 可选 |
### blocks.IdentRequest
| JSON 字段 | 类型 | 规则 |
|---|---|---|
| `id` | `int64` | 可选 |
| `identity` | `string` | 可选 |
### feed.AddTagRequest
| JSON 字段 | 类型 | 规则 |
|---|---|---|
| `tags` | `[]string` | 数组 |
### feed.CommentItem
| JSON 字段 | 类型 | 规则 |
|---|---|---|
| `identity` | `string` | 可选 |
| `postIdentity` | `string` | 可选 |
| `feedIdentity` | `string` | 可选 |
| `content` | `string` | 可选 |
| `subComment` | `[]feed.CommentItem` | 数组 |
### feed.CommentListReply
| JSON 字段 | 类型 | 规则 |
|---|---|---|
| `list` | `[]feed.CommentItem` | 数组 |
| `total` | `int64` | 可选 |
### feed.PostActionRequest
| JSON 字段 | 类型 | 规则 |
|---|---|---|
| `actionOp` | `string` | 可选 |
| `actionType` | `string` | 可选 |
| `identity` | `string` | 可选 |
### feed.TagListReply
| JSON 字段 | 类型 | 规则 |
|---|---|---|
| `tags` | `[]blocks.FeedTagItem` | 数组 |
| `total` | `int64` | 可选 |