Skip to content

products(商品模块)

(数据库表 products)

🍓商品列表

partcontent
url/products
methodGET
JS
// params(请求参数)
{
   pageNum:1, // 页数 
   pageSize:10,// 条数
}
// 返回参数
{
    "total": 1,
    "code": 200,
    "data": [],
    "message": "查询成功!"
}

🍓新增

partcontent
url/products
methodPOST
JS
// data(提交参数)
// 新增数据 
{
      "name": "智能手机",
      "description": "最新款智能手机,支持5G网络。",
      "category_id": 1,
      "price": 3999.99,
      "stock": 50,
      "sku": "SM-123456",
      "brand": "品牌A",
      "weight": 0.45,
      "dimensions": "15.5x7.5x0.8 cm",
      "color": "黑色",
      "size": "标准",
      "status": "available",
      "is_active": true,
      "is_featured": false,
      "is_on_sale": true,
      "image_url": "https://example.com/product_image.jpg",
      "additional_images": "https://example.com/product_image1.jpg,https://example.com/product_image2.jpg",
      "video_url": "https://example.com/product_video.mp4",
      "created_at": "2025-04-08T10:00:00",
      "updated_at": "2025-04-08T10:00:00",
      "deleted_at": null,
      "tags": "新品,限时折扣",
      "promotion_price": 2999.99,
      "rating": 4.5,
      "review_count": 120,
      "shipping_fee": 30.00,
      "supplier_id": 10
};

// 返回参数
{
    "code": 200,
    "message": "操作成功",
}

🍓修改

partcontent
url/products
methodPUT
JS
// data(请求参数)
{       
    'product_id': 1,
    "name": "智能手机",
    "description": "最新款智能手机,支持5G网络。",
    "category_id": 1,
    "price": 3999.99,
    "stock": 50,
    "sku": "SM-123456",
    "brand": "品牌A",
    "weight": 0.45,
    "dimensions": "15.5x7.5x0.8 cm",
    "color": "黑色",
    "size": "标准",
    "status": "available",
    "is_active": true,
    "is_featured": false,
    "is_on_sale": true,
    "image_url": "https://example.com/product_image.jpg",
    "additional_images": "https://example.com/product_image1.jpg,https://example.com/product_image2.jpg",
    "video_url": "https://example.com/product_video.mp4",
    "created_at": "2025-04-08T10:00:00",
    "updated_at": "2025-04-08T10:00:00",
    "deleted_at": null,
    "tags": "新品,限时折扣",
    "promotion_price": 2999.99,
    "rating": 4.5,
    "review_count": 120,
    "shipping_fee": 30.00,
    "supplier_id": 10
};

// 返回参数
{
    "code": 200,
    "message": "修改成功",
}

🍓单个详情

partcontent
url/products/${product_id}
methodGET
JS
// params(请求参数)
/products/${product_id}'(地址栏拼接id)

// 返回参数
{
    "code": 200,
    "data": {
        'product_id': 1,
        "name": "智能手机",
        "description": "最新款智能手机,支持5G网络。",
        "category_id": 1,
        "price": 3999.99,
        "stock": 50,
        "sku": "SM-123456",
        "brand": "品牌A",
        "weight": 0.45,
        "dimensions": "15.5x7.5x0.8 cm",
        "color": "黑色",
        "size": "标准",
        "status": "available",
        "is_active": true,
        "is_featured": false,
        "is_on_sale": true,
        "image_url": "https://example.com/product_image.jpg",
        "additional_images": "https://example.com/product_image1.jpg,https://example.com/product_image2.jpg",
        "video_url": "https://example.com/product_video.mp4",
        "created_at": "2025-04-08T10:00:00",
        "updated_at": "2025-04-08T10:00:00",
        "deleted_at": null,
        "tags": "新品,限时折扣",
        "promotion_price": 2999.99,
        "rating": 4.5,
        "review_count": 120,
        "shipping_fee": 30.00,
        "supplier_id": 10
    },
}

🍓删除

partcontent
url/products/${product_id}
methodDELETE
JS
// params(请求参数)
地址栏拼接id

// 返回参数
{
    code: 200,
    message: "操作成功",
}

🍓修改状态

partcontent
url/products/${product_id}
methodPUT
作用更新商品是否展示
JS
/products/status/${product_id}'(地址栏拼接id)

// data(提交参数)
{
    "isActive": 1
}


// 返回参数
{
    code: 200,
    message: "操作成功",
}

Released under the MIT License.