说说列表接口

接口说明

获取说说列表。支持分页查询和分类筛选,返回的说说内容会进行长度限制。

  • 接口URL: /api/shuoshuos/index
  • 请求方法: POST
  • 权限要求: 无需登录即可访问

请求参数

参数名 类型 必填 说明 示例值
page_numer number 页码,不传则返回全部数据 1
page_size number 每页条数,不传则返回全部数据 10
coll_path string 分类路径 "daily"

响应结构

typescript 复制代码
interface Response {
  code: number;      // 状态码
  message: string;   // 响应消息
  data?: {
    list: Array<{
      shuoshuo_id: number;     // 说说ID
      shuoshuo_text: string;   // 说说内容(超过60字符会被截断)
      shuoshuo_date: string;   // 发布日期
      shuoshuo_coll_id: number;// 分类ID
      sh_coll_name: string;    // 分类名称
      sh_coll_path: string;    // 分类路径
    }>;
    total: number;            // 总条数
  };
}

响应示例

json 复制代码
{
  "code": 0,
  "message": "success",
  "data": {
    "list": [
      {
        "shuoshuo_id": 1,
        "shuoshuo_text": "今天天气真好,出去散步了一圈,遇到了很多有趣的事情...",
        "shuoshuo_date": "2024-01-01",
        "shuoshuo_coll_id": 1,
        "sh_coll_name": "日常生活",
        "sh_coll_path": "daily"
      }
    ],
    "total": 1
  }
}

特殊说明

分页机制

  • page_numerpage_size 都不传时,返回全部数据
  • 分页从第1页开始,每页大小由 page_size 决定
  • 返回数据按发布日期降序排列(最新的说说在前)

内容处理

  • 说说内容超过60字符会被截断,末尾添加"..."
  • 如需查看完整内容,请使用说说详情接口

错误码说明

错误码 说明 处理建议
0 成功 -
500 服务器错误 请联系管理员

调用示例

基础查询

typescript 复制代码
const response = await fetch('/api/shuoshuos/index', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    page_numer: 1,
    page_size: 10
  })
});

分类筛选

typescript 复制代码
const response = await fetch('/api/shuoshuos/index', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    page_numer: 1,
    page_size: 10,
    coll_path: 'daily'
  })
});