HC小区接口文档

商品分类查询接口文档

一、接口名称

查询商品分类列表

二、接口描述

该接口用于查询商品分类信息,支持分页查询,返回符合条件的商品分类列表及总数。

三、接口路径

http://{ip}:{port}/app/productCategory.queryProductCategory

四、请求方法

GET

五、请求头

参数名称 必填 类型 描述
Authorization String 用户认证token,通过登录接口获取
app-id String 应用ID,系统分配
transaction-id String 请求流水号,格式:1000000000+YYYYMMDDhhmmss+6位序列
sign String 请求签名
req-time String 请求时间,格式:YYYYMMDDhhmmss

六、请求参数

6.1 查询参数

参数名称 必填 类型 描述
page Integer 当前页码(默认1)
row Integer 每页记录数(默认10)
storeId String 店铺ID(自动从上下文中获取)
categoryName String 分类名称(模糊查询)
parentCategoryId String 父分类ID
statusCd String 分类状态(如:0-有效,1-无效)

七、返回值

7.1 返回数据结构

参数名称 类型 描述
code String 返回码,0-成功,非0-失败
msg String 返回信息
data Object 返回数据
data.total Integer 总记录数
data.records List<ProductCategoryDto> 商品分类列表

7.2 ProductCategoryDto 结构

字段名 类型 描述
categoryId String 分类ID
categoryName String 分类名称
parentCategoryId String 父分类ID
storeId String 店铺ID
statusCd String 状态(0-有效,1-无效)
sortOrder Integer 排序权重
icon String 分类图标URL

八、示例请求

请求URL

GET http://127.0.0.1:8080/app/productCategory.queryProductCategory?page=1&row=10&categoryName=食品

请求头

{
  "Authorization": "Bearer xxxxxx",
  "app-id": "mall-goods",
  "transaction-id": "100000000020231001120000000001",
  "sign": "xxxxxx",
  "req-time": "20231001120000"
}

九、示例响应

成功响应

{
  "code": "0",
  "msg": "成功",
  "data": {
    "total": 5,
    "records": [
      {
        "categoryId": "1001",
        "categoryName": "食品",
        "parentCategoryId": "0",
        "storeId": "8001",
        "statusCd": "0",
        "sortOrder": 1,
        "icon": "http://xxx.com/food.png"
      },
      {
        "categoryId": "1002",
        "categoryName": "饮料",
        "parentCategoryId": "0",
        "storeId": "8001",
        "statusCd": "0",
        "sortOrder": 2,
        "icon": "http://xxx.com/drink.png"
      }
    ]
  }
}

失败响应

{
  "code": "1001",
  "msg": "店铺ID不能为空",
  "data": null
}

十、业务逻辑说明

  1. 参数校验:自动校验分页参数(page/row),并检查 storeId 是否有效。
  2. 数据查询:调用 IProductCategoryInnerServiceSMO 查询符合条件的分类列表及总数。
  3. 分页处理:根据 page 和 row 参数计算总页数。
  4. 返回结果:封装为 ResultVo 格式返回,包含分页信息和分类数据。

十一、注意事项

  • 该接口需要店铺权限,storeId 会自动从请求上下文中获取。
  • 支持模糊查询(如按分类名称搜索)。
  • 默认按 sortOrder 升序排序。