新闻资讯文档
益安
1. 创建新闻分类
Description
创建新闻类别
Method and URL Structure
| Method |
Resource URL |
| POST |
/news/category_list/ |
Request Parameters
| Name |
Description |
Required |
Default |
| name |
新闻分类名称 |
Yes |
|
| Name |
Description |
Required |
Default |
| Authorization |
Token 320a37f43fa80f52af27abe3b468d74204ccd180 |
Yes |
|
*Authorization的值为登录成功后返回值
Request
{ "name":"生活",}
cURL Example
curl -X POST -H 'Authorization: Token 320a37f43fa80f52af27abe3b468d74204ccd180' -d 'name=生活’ http://127.0.0.1:8000/news/category_list/
JSON Response
{"pk":3,"name":"生活"}
2. 获取所有新闻分类
Description
获取新闻类别
Method and URL Structure
| Method |
Resource URL |
| GET |
/news/category_list/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 320a37f43fa80f52af27abe3b468d74204ccd180 |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X GET -H 'Authorization: Token 320a37f43fa80f52af27abe3b468d74204ccd180' http://127.0.0.1:8000/news/category_list/
JSON Response
[{"pk":1,"name":"生活"},{"pk":2,"name":"政治"},{"pk":3,"name":"军事"}]
0. 获取今日头条新闻资讯
Description
首页头条新闻
Method and URL Structure
| Method |
Resource URL |
| GET |
/news/news_first/ |
Request Parameters
| Name |
Description |
Required |
Default |
| category |
新闻分类资源的pk/id |
Yes |
|
category: 新闻分类分为四种:热点资讯、专题活动、政策解读、安全咨询
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X GET http://127.0.0.1:8000/news/news_first/?category=1
取数据库中某新闻分类下的最新的一条数据
JSON Response
{ "pk": 1, "category": 1, "author": "root", "title": "消防员冒死抢救", "picture": "http://img5.imgtn.bdimg.com/it/u=3425851328,2681317699&fm=21&gp=0.jpg", "banner_url": "", "content": "河南郑州,燕庄附近一非法液化气罐装站突发爆炸,引发大火,造成7死1伤这一惨痛后果。", "click": "0", "create_time": "2016-07-07T03:22:24Z", "create_date": "07-07"}
1. 创建新闻资讯
Description
管理员添加新闻
Method and URL Structure
| Method |
Resource URL |
| POST |
/news/news_list/ |
Request Parameters
| Name |
Description |
Required |
Default |
| title |
新闻标题 |
Yes |
|
| content |
新闻内容 |
Yes |
|
| picture |
新闻图片 |
No |
|
| banner_url |
新闻大图 |
NO |
|
| category |
新闻分类的资源pk/id |
No |
|
| Name |
Description |
Required |
Default |
| Authorization |
Token 320a37f43fa80f52af27abe3b468d74204ccd180 |
Yes |
|
*Authorization的值为登录成功后返回值
Request
{ "title":"今天", "content":"今天很好", "picture":"http://banbao.chazidian.com/uploadfile/2016-01-25/s145368924044608.jpg", "category":1,}
cURL Example
curl -X POST -H 'Authorization: Token 320a37f43fa80f52af27abe3b468d74204ccd180' -d 'title=今天&content=今天过的好吗?&picture=http://banbao.chazidian.com/uploadfile/2016-01-25/s145368924044608.jpg&category=1' http://127.0.0.1:8000/news/news_list/
JSON Response
{ "pk":3, "author":"root", "category":1, "title":"未来呢", "content":"未来一片光明", "picture":"http://banbao.chazidian.com/uploadfile/2016-01-25/s145368924044608.jpg", "banner_url": "", "click":0, "create_time":"2016-04-12 10:30:20",}
2. 修改某条新闻资讯
Description
管理员修改新闻信息
Method and URL Structure
| Method |
Resource URL |
| PUT |
/news/news_detail/${pk}/ |
Request Parameters
| Name |
Description |
Required |
Default |
| title |
新闻标题 |
Yes |
|
| content |
新闻内容 |
Yes |
|
| picture |
新闻图片 |
No |
|
| banner_url |
新闻大图 |
NO |
|
| Name |
Description |
Required |
Default |
| Authorization |
Token 320a37f43fa80f52af27abe3b468d74204ccd180 |
Yes |
|
*Authorization的值为登录成功后返回值
Request
{ "title":"过年期间 教你如何安全优雅抢红包!", "content":"一年一度的春节即将到来,新年的年味儿也是越来越浓,洋溢着节日气息的“红包”更是在此氛围里满屏飞花。事实上,相较于过去传统的祝福话语,近两年在大大小小的群里“抢红包”俨然已成为全民竞相热捧的节日形式,如果这个过年不发或者抢点红包,都不好意思说自己用的是智能机。",}
cURL Example
curl -X PUT -H 'Authorization: Token 320a37f43fa80f52af27abe3b468d74204ccd180' -d 'title=红包&content=玩起来吧' http://127.0.0.1:8000/news/news_detail/1/
JSON Response
{ "pk":3, "author":"root", "category":1, "title":"未来呢", "content":"未来一片光明", "picture":"", "banner_url": "", "click":0, "create_time":"2016-04-12 10:30:20",}
3. 删除新闻
Description
管理员删除课程信息
Method and URL Structure
| Method |
Resource URL |
| DELETE |
/news/news_detail/${pk}/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 320a37f43fa80f52af27abe3b468d74204ccd180 |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X DELETE -H 'Authorization: Token 320a37f43fa80f52af27abe3b468d74204ccd180' http://127.0.0.1:8000/news/news_detail/1/
JSON Response
| Name |
Description |
Default |
| detail |
失败原因 |
Not found |
| status |
成功 |
204 |
4. 查看新闻详情
Description
用户查询某一新闻信息
Method and URL Structure
| Method |
Resource URL |
| GET |
/news/news_detail/${pk}/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X GET -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' http://127.0.0.1:8000/news/news_detail/1/
JSON Response
{ "pk":3, "author":"root", "category":1, "title":"未来呢", "content":"未来一片光明", "picture":"http://www.example.com.1.jpg/", "banner_url": "", "click":0, "create_time":"2016-04-12 10:30:20",}
5. 获取所有新闻信息
Description
用户获取所有新闻
Method and URL Structure
| Method |
Resource URL |
| GET |
/news/news_list/ |
Request Parameters
默认分页取数据库中最新的10条数据
| Name |
Description |
Required |
Default |
| page |
page Number |
Yes |
1 |
| category |
新闻资源分类pk/id |
No |
|
cURL Example
curl -X GET -d 'page=1' http://127.0.0.1:8000/news/news_list/?category=1
JSON Response
{ "count":12, "next":null, "previous":null, "results": [ { "pk":12, "author":"root", "category":1, "title":"未来呢", "content":"未来一片光明", "picture":"", "banner_url": "", "click":0, "create_time":"2016-04-12 10:30:20", }, { "pk":11, "author":"root", "category":1, "title":"未来呢", "content":"未来一片光明", "picture":"", "banner_url": "", "click":0, "create_time":"2016-04-12 10:30:20", }, ...... ]}
1. 创建Banner资讯
Description
管理员添加Banner
Method and URL Structure
| Method |
Resource URL |
| POST |
/news/banner_ad_list/ |
Request Parameters
| Name |
Description |
Required |
Default |
| title |
banner标题 |
Yes |
|
| content |
banner内容 |
No |
|
| banner_url |
banner图地址 |
Yes |
|
| link |
banner详情地址 |
No |
|
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
Request
{ "title":"宋仲基", "banner_url":"http://pic.nen.com.cn/0/16/01/38/16013888_913511.jpg",}
cURL Example
curl -X POST -H 'Authorization: Token 320a37f43fa80f52af27abe3b468d74204ccd180' -d 'title=宋仲基&banner_url=http://pic.nen.com.cn/0/16/01/38/16013888_913511.jpg' http://127.0.0.1:8000/news/banner_ad_list/
JSON Response
{ "pk":1, "author":"root", "title":" 宋仲基", "content":null, "link":null, "banner_url":"http://pic.nen.com.cn/0/16/01/38/16013888_913511.jpg", "click":0, "create_time":"2016-04-12 10:30:20",}
2. 修改某条banner资讯
Description
管理员修改banner信息
Method and URL Structure
| Method |
Resource URL |
| PUT |
/news/banner_ad_detail/${pk}/ |
Request Parameters
| Name |
Description |
Required |
Default |
| title |
banner标题 |
Yes |
|
| content |
banner内容 |
No |
|
| link |
banner详情地址 |
No |
|
| banner_url |
banner图地址 |
Yes |
|
| Name |
Description |
Required |
Default |
| Authorization |
Token 320a37f43fa80f52af27abe3b468d74204ccd180 |
Yes |
|
*Authorization的值为登录成功后返回值
Request
{ "title":"太阳的后裔", "banner_url":"http://pic.nen.com.cn/0/16/01/38/16013888_913511.jpg",}
cURL Example
curl -X PUT -H 'Authorization: Token 320a37f43fa80f52af27abe3b468d74204ccd180' -d 'title=太阳的后裔包&banner_url=http://pic.nen.com.cn/0/16/01/38/16013888_913511.jpg' http://127.0.0.1:8000/news/banner_ad_detail/1/
JSON Response
{ "pk":1, "author":"root", "title":"太阳的后裔", "content":null, "link":null, "banner_url":"http://pic.nen.com.cn/0/16/01/38/16013888_913511.jpg", "click":0, "create_time":"2016-04-12 10:30:20",}
3. 删除banner
Description
管理员删除banner信息
Method and URL Structure
| Method |
Resource URL |
| DELETE |
/news/banner_ad_detail/${pk}/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 320a37f43fa80f52af27abe3b468d74204ccd180 |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X DELETE -H 'Authorization: Token 320a37f43fa80f52af27abe3b468d74204ccd180' http://127.0.0.1:8000/news/banner_ad_detail/1/
JSON Response
| Name |
Description |
Default |
| detail |
失败原因 |
Not found |
| status |
成功 |
204 |
4. 查看banner详情
Description
用户查看某一banner信息
Method and URL Structure
| Method |
Resource URL |
| GET |
/news/banner_ad_detail/${pk}/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X GET -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' http://127.0.0.1:8000/news/banner_ad_detail/1/
JSON Response
{ "pk":1, "author":"teacher", "title":"太阳的后裔", "content":null, "link":null, "banner_url":"http://pic.nen.com.cn/0/16/01/38/16013888_913511.jpg", "click":0, "create_time":"2016-04-12 10:30:20",}
5. 获取所有banner信息
Description
用户获取所有banner
Method and URL Structure
| Method |
Resource URL |
| GET |
/news/banner_ad_list/ |
Request Parameters
默认分页取数据库中最新的10条数据
| Name |
Description |
Required |
Default |
| page |
page Number |
Yes |
1 |
cURL Example
curl -X GET http://127.0.0.1:8000/news/banner_ad_list/?page=1
JSON Response
{ "count":2, "next":null, "previous":null, "results": [ { "pk":2, "author":"root", "title":"太阳的后裔", "content":null, "link":null, "banner_url":"http://pic.nen.com.cn/0/16/01/38/16013888_913511.jpg", "click":0, "create_time":"2016-04-12 10:30:20", }, { "pk":1, "author":"root", "title":"太阳的后裔", "content":null, "link":null, "banner_url":"http://pic.nen.com.cn/0/16/01/38/16013888_913511.jpg", "click":0, "create_time":"2016-04-12 10:30:20", }, ...... ]}