接口文档示例

2,360 阅读1分钟
  1. 查询商品列表

接口功能:查询商品列表,返回所有商品的信息

请求URL:/api/products

请求方式:GET

请求参数:

参数名类型是否必填描述
keywordstring商品名称关键词
categorystring商品分类
minPricenumber最低价格
maxPricenumber最高价格
pagenumber分页页码,默认为1
pageSizenumber分页每页数量,默认为10

响应参数:

参数名类型是否必填描述
idnumber商品ID
namestring商品名称
pricenumber商品价格
descriptionstring商品描述

示例请求URL:/api/products?keyword=手机&category=数码&minPrice=1000&maxPrice=5000&page=2&pageSize=20

示例响应数据:

{
  "status": 200,
  "message": "OK",
  "data": [
    {
      "id": 1,
      "name": "iPhone 12",
      "price": 6999,
      "description": "苹果新品手机"
    },
    {
      "id": 2,
      "name": "华为Mate40",
      "price": 4999,
      "description": "华为新品手机"
    }
  ]
}

备注:本接口支持根据关键词、分类、价格区间等条件进行商品查询,并支持分页查询。如果不传入任何参数,则返回所有商品信息。