mirror of
https://ids-dev.idsbuybuybuy.com/ids-ecommerce/ids-svc-product.git
synced 2026-11-29 16:57:41 +08:00
Update README to include detailed API interface specifications for CreateProduct, GetProduct, and ListCategoryProducts, enhancing clarity on request and response structures.
This commit is contained in:
parent
ac7ca612a6
commit
fb6582989d
57
README.md
57
README.md
@ -14,6 +14,63 @@ IDS 电商矩阵中的**商品域微服务**,负责 SPU/SKU 主数据、分类
|
|||||||
|
|
||||||
契约定义见 [`ids-proto`](https://llms.idsbuybuybuy.com/ecommerce/ids-proto) 的 `proto/ids/product/v1/product.proto`。
|
契约定义见 [`ids-proto`](https://llms.idsbuybuybuy.com/ecommerce/ids-proto) 的 `proto/ids/product/v1/product.proto`。
|
||||||
|
|
||||||
|
## 接口清单
|
||||||
|
|
||||||
|
当前商品服务对外暴露 3 个接口,REST 路径由 `google.api.http` 注解提供给 APISIX gRPC-Transcode 使用。
|
||||||
|
|
||||||
|
| RPC | REST | 请求 | 响应 | 说明 |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| `CreateProduct` | `POST /v1/products` | `CreateProductRequest` | `CreateProductResponse` | 创建商品 SPU,可同时提交 SKU 列表 |
|
||||||
|
| `GetProduct` | `GET /v1/products/{product_id}` | `GetProductRequest` | `GetProductResponse` | 按商品 ID 查询商品详情,返回 SPU 与 SKU 列表 |
|
||||||
|
| `ListCategoryProducts` | `GET /v1/categories/{category_id}/products?page=1&page_size=20` | `ListCategoryProductsRequest` | `ListCategoryProductsResponse` | 按分类/分组 ID 分页查询商品列表 |
|
||||||
|
|
||||||
|
### `CreateProduct`
|
||||||
|
|
||||||
|
| 字段 | 类型 | 必填 | 说明 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `product_id` | `string` | 是 | 商品 SPU ID,由调用方生成 |
|
||||||
|
| `spu_no` | `string` | 是 | SPU 编码,未删除商品内唯一 |
|
||||||
|
| `title` | `string` | 是 | 商品标题 |
|
||||||
|
| `selling_point` | `string` | 否 | 商品卖点 |
|
||||||
|
| `status` | `ProductStatus` | 是 | 商品状态:`DRAFT` / `ON_SALE` / `OFF_SALE` |
|
||||||
|
| `skus` | `CreateProductSKU[]` | 否 | 创建时附带的 SKU 列表 |
|
||||||
|
|
||||||
|
`CreateProductSKU` 字段:
|
||||||
|
|
||||||
|
| 字段 | 类型 | 必填 | 说明 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `sku_id` | `string` | 是 | SKU ID,由调用方生成 |
|
||||||
|
| `name` | `string` | 是 | SKU 名称 |
|
||||||
|
| `price` | `int64` | 是 | 售价,单位:分 |
|
||||||
|
| `available_quantity` | `int32` | 是 | 初始可售库存 |
|
||||||
|
| `attributes_json` | `string` | 否 | 规格属性 JSON 字符串 |
|
||||||
|
|
||||||
|
### `GetProduct`
|
||||||
|
|
||||||
|
| 字段 | 类型 | 必填 | 说明 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `product_id` | `string` | 是 | 商品 SPU ID |
|
||||||
|
|
||||||
|
响应 `product` 包含 SPU 基础信息、SKU 列表、`created_at`、`updated_at`。
|
||||||
|
|
||||||
|
### `ListCategoryProducts`
|
||||||
|
|
||||||
|
| 字段 | 类型 | 必填 | 说明 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `category_id` | `string` | 是 | 分类/分组节点 ID,对应 `product.product_category.id` |
|
||||||
|
| `page` | `int32` | 否 | 页码,从 `1` 开始;未传或小于 `1` 时按 `1` 处理 |
|
||||||
|
| `page_size` | `int32` | 否 | 每页数量;未传或小于 `1` 时按 `20` 处理,大于 `100` 时截断为 `100` |
|
||||||
|
|
||||||
|
分页响应字段:
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| `products` | `Product[]` | 当前页商品列表 |
|
||||||
|
| `page` | `int32` | 当前页码 |
|
||||||
|
| `page_size` | `int32` | 当前每页数量 |
|
||||||
|
| `total` | `int64` | 分类/分组下商品总数 |
|
||||||
|
| `total_pages` | `int32` | 总页数 |
|
||||||
|
|
||||||
## 技术栈
|
## 技术栈
|
||||||
|
|
||||||
| 项 | 选型 |
|
| 项 | 选型 |
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user