📰
imarket校园集市
  • Welcome
  • Introduce(简介)
  • Getting Started
    • Quickstart(快速开始)
  • API
    • 安全认证
    • Auth(认证与授权)
    • Account(账户管理)
    • Admin(管理员功能)
    • Post(帖子管理)
    • User(用户相关)
    • Comments(评论管理)
    • Message(站内消息)
    • Image(图片管理)
    • Search(搜索功能)
  • Plugin
    • Introduce(插件系统简介)
    • Start(快速上手)
    • Dependency Injection(依赖注入)
    • API (状态接口)
  • Database
    • Tables(数据库表结构)
    • create_tables_script(数据库创建脚本)
Powered by GitBook
On this page
  • GET /api/Comments/{postid}
  • POST /api/Comments/Create
  • GET /api/Comments/Delete
  • GET /api/Comments/Like
  • GET /api/Comments/UnLike
  1. API

Comments(评论管理)

GET /api/Comments/{postid}

  • 描述: 获取指定帖子的评论。

  • 参数:

    • postid (string, required): 帖子ID

  • 响应: 200 OK

请求示例

//api/Comments/:postid

示例代码

const myHeaders = new Headers();
myHeaders.append("Authorization", "<API Key>");

const requestOptions = {
  method: "GET",
  headers: myHeaders,
  redirect: "follow"
};

fetch("//api/Comments/:postid", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

返回示例

{
  "success": true,
  "comments": [
    {
      "id": 321,
      "nickname": "admin imarket",
      "username": "admin",
      "userAvatar": "test",
      "content": "这是第一个评论",
      "isLike": false,
      "likeNum": 0,
      "createdAt": "2025-01-22T16:58:20"
    }
  ]
}

POST /api/Comments/Create

  • 描述: 发表评论。

  • 请求体:

    • application/json: CommentPostRequest 对象

    • text/json: CommentPostRequest 对象

    • application/*+json: CommentPostRequest 对象

  • 响应: 200 OK

请求示例

{
  "content": "<string>",
  "postId": "<ulong>"
}

示例代码

const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "<API Key>");

const raw = JSON.stringify({
  "content": "<string>",
  "postId": "<ulong>"
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("//api/Comments/Create", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

返回示例

{
  "success": true,
  "commentId": 12
}

GET /api/Comments/Delete

  • 描述: 删除评论。

  • 参数:

    • commentId (string, required): 评论ID

  • 响应: 200 OK

请求示例

//api/Comments/Delete?commentId=<ulong>

示例代码

const myHeaders = new Headers();
myHeaders.append("Authorization", "<API Key>");

const requestOptions = {
  method: "GET",
  headers: myHeaders,
  redirect: "follow"
};

fetch("//api/Comments/Delete?commentId=<string>", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

返回示例

{
  "success": true
}

GET /api/Comments/Like

  • 描述: 点赞评论。

  • 参数:

    • commentId (string, required): 评论ID

  • 响应: 200 OK

请求示例

//api/Comments/Like?commentId=<ulong>

示例代码

const myHeaders = new Headers();
myHeaders.append("Authorization", "<API Key>");

const requestOptions = {
  method: "GET",
  headers: myHeaders,
  redirect: "follow"
};

fetch("//api/Comments/Like?commentId=<string>", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

返回示例

{
  "success": true
}

GET /api/Comments/UnLike

  • 描述: 取消点赞评论。

  • 参数:

    • commentId (string, required): 评论ID

  • 响应: 200 OK

请求示例

//api/Comments/UnLike?commentId=<ulong>

示例代码

const myHeaders = new Headers();
myHeaders.append("Authorization", "<API Key>");

const requestOptions = {
  method: "GET",
  headers: myHeaders,
  redirect: "follow"
};

fetch("//api/Comments/UnLike?commentId=<ulong>", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

返回示例

{
  "success": true
}
PreviousUser(用户相关)NextMessage(站内消息)

Last updated 3 months ago