📰
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/Search/Posts
  • GET /api/Search/HotRanking
  1. API

Search(搜索功能)

GET /api/Search/Posts

  • 描述: 搜索帖子。

  • 参数:

    • keyWord (string, required): 关键词

    • page (integer, optional, default=1): 页码

    • pageSize (integer, optional, default=10): 每页大小

  • 响应: 200 OK

请求示例

//api/Search/Posts?keyWord=<string>&page=1&pageSize=10

示例代码

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

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

fetch("//api/Search/Posts?keyWord=<string>&page=1&pageSize=10", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

返回示例

{
  "success": true,
  "posts": [
    {
      "id": 1,
      "title": "第一个帖子",
      "nickname": "admin imarket",
      "avatar": "test",
      "content": "这个是第一个帖子",
      "favoriteNums": 1,
      "likeNums": 0,
      "createdAt": "2025-01-22T16:41:31"
    }
  ]
}

GET /api/Search/HotRanking

  • 描述: 获取热门排行榜。

返回值为最近一周的最多点赞和最多收藏10篇帖子,如果帖子没有点赞或收藏,则可能少于10篇

  • 响应: 200 OK

请求示例

//api/Search/HotRanking

示例代码

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

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

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

返回示例

{
  "success": true,
  "like": [
    {
      "id": 1,
      "title": "第一个帖子",
      "content": "这个是第一个帖子",
      "userId": 3214,
      "createdAt": "2025-01-22T16:41:31",
      "likeCount": 1
    }
  ],
  "favorite": [
    {
      "id": 2,
      "title": "第一个帖子",
      "content": "这个是第一个帖子",
      "userId": 3214,
      "createdAt": "2025-01-22T16:41:31",
      "favoriteCount": 1
    }
  ]
}
PreviousImage(图片管理)NextIntroduce(插件系统简介)

Last updated 3 months ago