Skip to content

后台商品管理

sfyr111 edited this page Feb 26, 2018 · 1 revision

POST 添加或更新产品

{{host}}/manage/product/saveOrUpdate

request

name
categoryId
subtitle
subImages
detail
price
stock
status
id: 指定商品 id 为更新, 无指定 id 添加商品

response

{
    "status": 0,
    "msg": "添加产品成功",
    "data": {
        "createTime": "2018-02-26T08:23:03.455Z",
        "updateTime": "2018-02-26T08:23:03.455Z",
        "id": 8,
        "name": "产品名称5",
        "categoryId": "1",
        "subtitle": "副标题",
        "subImages": "url1,url2",
        "detail": "详情",
        "price": "12.17",
        "stock": "1000",
        "status": "1",
        "mainImage": "url1"
    }
}

PUT 修改商品销售状态

{{host}}/manage/product/setSaleStatus

request

id
status: {"ON_SALE":{"CODE":1,"VALUE":"在售"},"NO_SALE":{"CODE":2,"VALUE":"下架"},"DEL_SALE":{"CODE":3,"VALUE":"删除"}}

response

{
    "status": 0,
    "msg": "修改产品销售状态成功",
    "data": {
        "id": 1,
        "categoryId": 1,
        "name": "产品名称1",
        "subtitle": "副标题",
        "mainImage": "url1",
        "subImages": "url1,url2",
        "detail": "详情",
        "price": "12.13",
        "stock": 998,
        "status": "1",
        "createTime": "2018-02-14T17:39:36.000Z",
        "updateTime": "2018-02-26T09:04:41.721Z"
    }
}

GET 获取商品详情

{{host}}/manage/product/detail/:productId

response

{
    "status": 0,
    "msg": null,
    "data": {
        "id": 1,
        "categoryId": 1,
        "name": "产品名称1",
        "subtitle": "副标题",
        "mainImage": "url1",
        "subImages": "url1,url2",
        "detail": "详情",
        "price": "12.13",
        "stock": 998,
        "status": 1,
        "createTime": "2018-02-14T17:39:36.000Z",
        "updateTime": "2018-02-26T09:04:41.000Z"
    }
}

GET 后台产品列表获取

{{host}}/manage/product/list?pageNum=1&pageSize=10

request

pageNum
pageSize

response

{
    "status": 0,
    "msg": null,
    "data": {
        "pageNum": "1",
        "pageSize": "10",
        "list": [
            {
                "id": 1,
                "categoryId": 1,
                "name": "产品名称1",
                "subtitle": "副标题",
                "mainImage": "url1",
                "subImages": "url1,url2",
                "detail": "详情",
                "price": "12.13",
                "stock": 998,
                "status": 1,
                "createTime": "2018-02-14T17:39:36.000Z",
                "updateTime": "2018-02-26T09:04:41.000Z"
            }
        ],
        "total": 5,
        "host": "oss-cn-hangzhou.aliyuncs.com"
    }
}

GET 后台使用名称搜索商品列表

{{host}}/manage/product/search?productName=产品&pageNum=1&pageSize=10

request

productName: 关键字
pageNum
pageSize

response

{
    "status": 0,
    "msg": null,
    "data": {
        "pageNum": "1",
        "pageSize": "10",
        "list": [
            {
                "id": 1,
                "categoryId": 1,
                "name": "产品名称1",
                "subtitle": "副标题",
                "mainImage": "url1",
                "subImages": "url1,url2",
                "detail": "详情",
                "price": "12.13",
                "stock": 998,
                "status": 1,
                "createTime": "2018-02-14T17:39:36.000Z",
                "updateTime": "2018-02-26T09:04:41.000Z"
            }
        ],
        "total": 5,
        "host": "oss-cn-hangzhou.aliyuncs.com"
    }
}

GET 后台商品 id 搜索

{{host}}/manage/product/search?productId=1

request

productId

response

{
    "status": 0,
    "msg": null,
    "data": {
        "product": {
            "id": 1,
            "categoryId": 1,
            "name": "产品名称1",
            "subtitle": "副标题",
            "mainImage": "url1",
            "subImages": "url1,url2",
            "detail": "详情",
            "price": "12.13",
            "stock": 998,
            "status": 1,
            "createTime": "2018-02-14T17:39:36.000Z",
            "updateTime": "2018-02-26T09:04:41.000Z"
        },
        "host": "oss-cn-hangzhou.aliyuncs.com"
    }
}

PUT 后台上传图片

{{host}}/manage/upload

request

params

file: 文件
fields: {} 其他字段

headers

form-data

response

{
    "status": 0,
    "msg": "上传图片成功",
    "data": {
        "filename": "shipping1519636340300.jpeg",
        "url": "localhost:7001/public/shipping1519636340300.jpeg",
        "fields": {
            "a": "1"
        }
    }
}