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

User(用户相关)

GET /api/User/Posts

  • 描述: 获取用户发布的帖子。

  • 参数:

    • username (string, required): 用户名

  • 响应: 200 OK

请求示例

//api/User/Posts?username=<string>&page=1&pageSize=10

示例代码

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

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

fetch("//api/User/Posts?username=<string>", 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": "/images/defaultAvatar.png",
      "content": "这是第一篇帖子",
      "favoriteNums": 0,
      "likeNums": 0,
      "createdAt": "2025-01-22T14:09:56"
    }
  ]
}

GET /api/User/Info

  • 描述: 获取用户信息。

  • 参数:

    • username (string, required): 用户名

  • 响应: 200 OK

请求示例

//api/User/Info?username=<string>

示例代码

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

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

fetch("//api/User/Info?username=<string>", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

返回示例

{
  "id": 1,
  "username": "admin",
  "nickname": "admin imarket",
  "avatar": "test",
  "status": 1
}

PreviousPost(帖子管理)NextComments(评论管理)

Last updated 3 months ago