Files
pyGoEdge-UserPanel/reference/goedge 文档/PostService.md
2025-11-18 03:36:49 +08:00

4.8 KiB
Raw Blame History

PostService

文章管理服务


countPosts

计算文章数量

  • 角色:admin
  • HTTPPOST https://backend.dooki.cloud/PostService/countPosts
  • RPCrpc countPosts(CountPostsRequest) returns (RPCCountResponse);

请求对象 (CountPostsRequest)

{
  "postCategoryId": "int64 // 分类ID",
  "productCode": "string // 产品代号",
  "publishedOnly": "bool // 只列出已发布的"
}

响应对象 (RPCCountResponse)

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

调用示例

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

createPost

创建文章

  • 角色:admin
  • HTTPPOST https://backend.dooki.cloud/PostService/createPost
  • RPCrpc createPost(CreatePostRequest) returns (CreatePostResponse);

请求对象 (CreatePostRequest)

{
  "postCategoryId": "int64 // 文章分类ID",
  "type": "string // 类型normal, url",
  "productCode": "string // 产品代号",
  "subject": "string // 标题",
  "url": "string // 跳转的URLtype=url",
  "body": "string // 文章内容type=normal"
}

响应对象 (CreatePostResponse)

{
  "postId": "int64 // 文章ID"
}

调用示例

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

deletePost

删除文章

  • 角色:admin
  • HTTPPOST https://backend.dooki.cloud/PostService/deletePost
  • RPCrpc deletePost(DeletePostRequest) returns (RPCSuccess);

请求对象 (DeletePostRequest)

{
  "postId": "int64 // 文章ID"
}

响应对象 (RPCSuccess)

{}

调用示例

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

findPost

查询单篇文章

  • 角色:admin, user
  • HTTPPOST https://backend.dooki.cloud/PostService/findPost
  • RPCrpc findPost(FindPostRequest) returns (FindPostResponse);

请求对象 (FindPostRequest)

{
  "postId": "int64 // 文章ID"
}

响应对象 (FindPostResponse)

{
  "post": "Post // 文章信息"
}

调用示例

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

listPosts

列出单页文章

  • 角色:admin, user
  • HTTPPOST https://backend.dooki.cloud/PostService/listPosts
  • RPCrpc listPosts(ListPostsRequest) returns (ListPostsResponse);

请求对象 (ListPostsRequest)

{
  "offset": "int64 // 读取位置",
  "size": "int64 // 数量通常不能小于0",
  "productCode": "string // 产品代号",
  "postCategoryId": "int64 // 分类ID",
  "postCategoryCode": "string // 分类代号",
  "excludingPostCategoryCode": "string // 排除的分类代号",
  "publishedOnly": "bool // 只列出已发布的",
  "containsBody": "bool // 是否包含文章内容"
}

响应对象 (ListPostsResponse)

{
  "posts": "[]Post // 文章列表"
}

调用示例

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

publishPost

发布文章

  • 角色:admin
  • HTTPPOST https://backend.dooki.cloud/PostService/publishPost
  • RPCrpc publishPost(PublishPostRequest) returns (RPCSuccess);

请求对象 (PublishPostRequest)

{
  "postId": "int64 // 文章ID"
}

响应对象 (RPCSuccess)

{}

调用示例

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

updatePost

修改文章

  • 角色:admin
  • HTTPPOST https://backend.dooki.cloud/PostService/updatePost
  • RPCrpc updatePost(UpdatePostRequest) returns (RPCSuccess);

请求对象 (UpdatePostRequest)

{
  "postId": "int64 // 文章ID",
  "postCategoryId": "int64 // 文章分类ID",
  "productCode": "string // 产品代号",
  "subject": "string // 标题",
  "type": "string // 类型normal, url",
  "url": "string // 跳转的URLtype=url",
  "body": "string // 文章内容type=normal"
}

响应对象 (RPCSuccess)

{}

调用示例

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