普兆健康管家后端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

4.6 KiB

小程序基础查询接口文档

概述

本文档描述了小程序基础的不需要登录的查询接口,包括产品、Banner、配置信息等模块的查询功能。

接口列表

1. 产品模块 (Product)

1.1 产品列表查询

  • 接口地址: GET /applet/product/list
  • 接口描述: 分页查询产品,支持按分类、关键词筛选
  • 请求参数:
    • type (必填): 产品类型
    • pageNo (可选): 页码,默认1
    • pageSize (可选): 每页大小,默认10
    • classId (可选): 分类ID
    • keyword (可选): 关键词,支持产品名称、描述、详情模糊搜索
  • 响应示例:
{
  "success": true,
  "message": "操作成功!",
  "code": 200,
  "result": {
    "records": [
      {
        "id": "xxx",
        "name": "产品名称",
        "info": "产品描述",
        "type": "产品类型",
        "classId": "分类ID",
        "originalPrice": 100.00,
        "currentPrice": 80.00,
        "unit": "单位",
        "detail": "产品详情",
        "sold": 100,
        "content": "产品内容"
      }
    ],
    "total": 100,
    "size": 10,
    "current": 1
  }
}

1.2 产品详情查询

  • 接口地址: GET /applet/product/detail
  • 接口描述: 获取单个产品详细信息
  • 请求参数:
    • id (必填): 产品ID
  • 响应示例:
{
  "success": true,
  "message": "操作成功!",
  "code": 200,
  "result": {
    "id": "xxx",
    "name": "产品名称",
    "info": "产品描述",
    "type": "产品类型",
    "classId": "分类ID",
    "originalPrice": 100.00,
    "currentPrice": 80.00,
    "unit": "单位",
    "detail": "产品详情",
    "sold": 100,
    "content": "产品内容"
  }
}

1.3 产品分类查询

  • 接口地址: GET /applet/product/category
  • 接口描述: 根据类型查询产品分类
  • 请求参数:
    • type (必填): 产品类型
  • 响应示例:
{
  "success": true,
  "message": "操作成功!",
  "code": 200,
  "result": [
    {
      "id": "xxx",
      "name": "分类名称",
      "description": "分类描述",
      "sortOrder": 1,
      "type": "产品类型"
    }
  ]
}

2. Banner模块 (Banner)

2.1 Banner列表查询

  • 接口地址: GET /applet/banner/list
  • 接口描述: 获取Banner列表,按类型分组,按排序字段排序
  • 请求参数: 无
  • 响应示例:
{
  "success": true,
  "message": "操作成功!",
  "code": 200,
  "result": {
    "home": [
      {
        "id": "xxx",
        "imageUrl": "图片地址",
        "linkUrl": "跳转链接",
        "sortOrder": 1,
        "type": "home"
      }
    ],
    "product": [
      {
        "id": "xxx",
        "imageUrl": "图片地址",
        "linkUrl": "跳转链接",
        "sortOrder": 1,
        "type": "product"
      }
    ]
  }
}

3. 配置信息模块 (Config)

3.1 配置列表查询

  • 接口地址: GET /applet/config/list
  • 接口描述: 查询所有配置信息
  • 请求参数: 无
  • 响应示例:
{
  "success": true,
  "message": "操作成功!",
  "code": 200,
  "result": [
    {
      "id": "xxx",
      "code": "配置编码",
      "info": "配置描述",
      "content": "配置内容",
      "type": "配置类型"
    }
  ]
}

技术特点

  1. Lambda查询: 所有数据库查询都使用MyBatis-Plus的LambdaQueryWrapper,提供类型安全的查询
  2. 模块化设计: 按业务模块分类,每个模块独立的Controller和Service
  3. 复用性高: 数据库操作复用demo模块的Mapper,避免重复代码
  4. 统一响应: 使用统一的Result响应格式
  5. 参数校验: 必填参数校验,可选参数支持默认值
  6. 日志记录: 所有接口都有详细的日志记录

使用示例

查询产品列表

curl -X GET "http://localhost:8080/applet/product/list?type=1&pageNo=1&pageSize=10&keyword=测试"

查询产品详情

curl -X GET "http://localhost:8080/applet/product/detail?id=xxx"

查询产品分类

curl -X GET "http://localhost:8080/applet/product/category?type=1"

查询Banner列表

curl -X GET "http://localhost:8080/applet/banner/list"

查询配置列表

curl -X GET "http://localhost:8080/applet/config/list"

注意事项

  1. 所有接口都不需要登录认证
  2. 产品列表查询的type参数为必填项
  3. 分页参数pageNo从1开始
  4. 关键词搜索支持产品名称、描述、详情的模糊匹配
  5. Banner按类型分组返回,便于前端按需使用
  6. 配置信息按编码排序返回