商品
金色童年
创建一个商品
Method and URL Structure
Method |
Resource URL |
POST |
/market/product/create/ |
Request Paramaters
Name |
Description |
Required |
Defalut |
category |
分类 |
YES |
|
name |
名称 |
YES |
|
price |
价格 |
YES |
|
cover |
封面图片 url |
YES |
|
desc |
描述 |
YES |
|
desc_files |
详情页面图片列表 |
YES |
|
Request Data
{
'category': category.pk,
'name':u'产品第一',
'price':99.0,
'cover': 'http://cover.example.com/cover.png',
'desc_files': 'http://img.example.com/file1.png,''http://img.example.com/fil2.jpg',
}
cURL Example
curl -X POST -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\
--data '{...}' http://localhost/product/create/
Response
{
"pk":7,
"category":24,
"category_name":"P2",
"name":"商品第一",
"price":"99.00",
"cover":"http://cover.example.com/cover.png",
"file_list":[
"http://img.example.com/file1.png",
"http://img.example.com/file2.jpg"
]
}
获取、更新、删除商品
Method and URL Structure
Method |
Resource URL |
GET |
/market/product/${product pk} |
PUTH |
/market/product/${product pk} |
PATCH |
/market/product/${product pk} |
DETEL |
/market/product/${product pk} |
Request Paramaters
Name |
Description |
Required |
Defalut |
category |
分类 |
YES |
|
name |
名称 |
YES |
|
price |
价格 |
YES |
|
cover |
封面图片 url |
YES |
|
desc |
描述 |
YES |
|
desc_files |
详情页面图片列表 |
YES |
|
Request Data
{
'category': category.pk,
'name':u'产品第一',
'price':99.0,
'cover': 'http://cover.example.com/cover.png',
'desc_files': 'http://img.example.com/file1.png,''http://img.example.com/fil2.jpg',
}
cURL Example
curl -X PUT -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\
--data '{...}' http://localhost/product/create/
Response
{
"pk":7,
"category":24,
"category_name":"P2",
"name":"商品第一",
"price":"99.00",
"evaluation_data":{
"count":0,
"bad_count":0,
"middle_count":0,
"good_count":0
},
"cover":"http://cover.example.com/cover.png",
"file_list":[
"http://img.example.com/file1.png",
"http://img.example.com/file2.jpg"
]
}
获取商品列表
Method and URL Structure
Method |
Resource URL |
GET |
/market/products/ |
Request Parameters
Name |
Description |
Required |
Default |
category |
分类 |
YES |
|
page |
页码 |
NO |
1 |
page_size |
每页数 |
NO |
10 |
owner |
商铺 |
NO |
|
cURL Example
curl -X PUT -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\
--data '{...}' http://localhost/products/?category=124
Response
{
"count":3,
"next":null,
"previous":null,
"results":[{
"pk":7,
"category":24,
"category_name":"P2",
"name":"商品第一",
"price":"99.00",
"use_point": true,
"evaluation_data":{
"count":0,
"bad_count":0,
"middle_count":0,
"good_count":0
},
"cover":"http://cover.example.com/cover.png",
"file_list":[
"http://img.example.com/file1.png",
"http://img.example.com/file2.jpg"
]
}...]
}
获取商品评价列表
Method and URL Structure
Method |
Resource URL |
GET |
/market/product/evaluations/${product pk} |
Request Parameters
No Applicated
cURL Example
curl http://localhost/products/evaluations/1234/
{
"count":2,
"next":null,
"previous":null,
"results":[{
"product":36,
"scores":5,
"scores_display":"五星",
"image":"http://example.com/xx.png",
"content":"评价产品而不是定单",
"created":"2016-10-20T17:05:20.835628",
"owner":{
"owner":27,
"nickname":"xiaoming",
"avatar_url":"http://www.example.com/xiaoming.jpg",
"slogan":"xiaoming's slogan"
}
},... ]
}