Post(帖子管理)
GET /api/Post/Posts
描述: 获取帖子列表。
参数:
page(integer, optional, default=1): 页码pageSize(integer, optional, default=10): 每页大小
响应: 200 OK
请求示例
//api/Post/Posts?page=1&pageSize=10示例代码
const myHeaders = new Headers();
myHeaders.append("Authorization", "<API Key>");
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("//api/Post/Posts?page=1&pageSize=10", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));返回示例
GET /api/Post/{id}
描述: 获取指定帖子详情。
参数:
id(string, required): 帖子ID
响应: 200 OK
请求示例
示例代码
返回示例
GET /api/Post/Categories
描述: 获取分类列表。
响应: 200 OK
请求示例
示例代码
返回示例
GET api/Post/Categories/:id
描述: 根据分类 ID 获取分类信息。
路径参数:
id(string, required): 分类的唯一标识符。
响应:
200 OK: 返回分类信息。
404 Not Found: 分类不存在。
请求示例:
javascript复制
返回示例:
成功:
json复制
分类不存在:
json复制
接口逻辑说明
获取分类信息:
根据路径参数
id调用postCategoriesService.GetCategoryByIdAsync(id)获取分类信息。如果分类不存在,返回
404 Not Found。
返回结果:
如果分类存在,返回
200 OK和分类信息。
GET /api/Post/CategorisedPosts
描述: 获取指定分类的帖子。
参数:
categoryId(string, required): 分类IDpage(integer, optional, default=1): 页码pageSize(integer, optional, default=10): 每页大小
响应: 200 OK
请求示例
示例代码
返回示例
POST /api/Post/Create
描述: 创建帖子。
请求体:
application/json:CreatePostRequest对象text/json:CreatePostRequest对象application/*+json:CreatePostRequest对象
响应: 200 OK
请求示例
示例代码
详情查看图片上传api页面
Image(图片管理)返回示例
GET /api/Post/Delete
描述: 删除帖子。
参数:
postId(string, required): 帖子ID
响应: 200 OK
请求示例
示例代码
返回示例
GET /api/Post/Finish
描述: 标记帖子为完成。
参数:
postId(string, required): 帖子ID
响应: 200 OK
请求示例
示例代码
返回示例
GET /api/Post/Favorite
描述: 收藏帖子。
参数:
postId(string, required): 帖子ID
响应: 200 OK
请求示例
示例代码
返回示例
GET /api/Post/Unfavorite
描述: 取消收藏帖子。
参数:
postId(string, required): 帖子ID
响应: 200 OK
请求示例
示例代码
返回示例
GET /api/Post/Like
描述: 点赞帖子。
参数:
postId(string, required): 帖子ID
响应: 200 OK
请求示例
示例代码
返回示例
GET /api/Post/Unlike
描述: 取消点赞帖子。
参数:
postId(string, required): 帖子ID
响应: 200 OK
请求示例
示例代码
返回示例
GET /api/Post/GetFavorites
描述: 获取收藏的帖子列表。
参数:
page(integer, optional, default=1): 页码pageSize(integer, optional, default=10): 每页大小
响应: 200 OK
请求示例
示例代码
返回示例
Last updated