Showing
4 changed files
with
38 additions
and
7 deletions
@@ -13,12 +13,17 @@ const INVALID_CONTENT = '内容[content]都不能为空'; | @@ -13,12 +13,17 @@ const INVALID_CONTENT = '内容[content]都不能为空'; | ||
13 | 13 | ||
14 | const article = { | 14 | const article = { |
15 | /** | 15 | /** |
16 | - * 所有文章 | 16 | + * 文章列表 |
17 | * @param req | 17 | * @param req |
18 | * @param res | 18 | * @param res |
19 | */ | 19 | */ |
20 | - all(req, res) { | ||
21 | - req.ctx(ArticleModel).allArticles() | 20 | + list(req, res) { |
21 | + // const query = req.query; | ||
22 | + // const pageNo = query.pageNo; | ||
23 | + // const popular = query.popular || false; | ||
24 | + // const pageSize = query.pageSize; | ||
25 | + | ||
26 | + req.ctx(ArticleModel).articleList() | ||
22 | .then(result => { | 27 | .then(result => { |
23 | res.json({ | 28 | res.json({ |
24 | code: 200, | 29 | code: 200, |
@@ -64,6 +69,7 @@ const article = { | @@ -64,6 +69,7 @@ const article = { | ||
64 | .then(() => { | 69 | .then(() => { |
65 | res.json({ | 70 | res.json({ |
66 | code: 200, | 71 | code: 200, |
72 | + data: {id}, | ||
67 | message: ADD_ARTICLE_SUCCESS | 73 | message: ADD_ARTICLE_SUCCESS |
68 | }); | 74 | }); |
69 | }); | 75 | }); |
@@ -16,10 +16,10 @@ class ArticleModel extends global.yoho.BaseModel { | @@ -16,10 +16,10 @@ class ArticleModel extends global.yoho.BaseModel { | ||
16 | } | 16 | } |
17 | 17 | ||
18 | /** | 18 | /** |
19 | - * 获取所有文章 | 19 | + * 获取文章列表 |
20 | * @returns {*} | 20 | * @returns {*} |
21 | */ | 21 | */ |
22 | - allArticles() { | 22 | + articleList() { |
23 | return mysqlCli.query(`select * from ${TABLE_ACT_ARTICLE}`); | 23 | return mysqlCli.query(`select * from ${TABLE_ACT_ARTICLE}`); |
24 | } | 24 | } |
25 | 25 |
@@ -8,7 +8,7 @@ const router = express.Router(); // eslint-disable-line | @@ -8,7 +8,7 @@ const router = express.Router(); // eslint-disable-line | ||
8 | const {auth} = require('../../middleware'); | 8 | const {auth} = require('../../middleware'); |
9 | const article = require('./controllers/article'); | 9 | const article = require('./controllers/article'); |
10 | 10 | ||
11 | -router.get('/all', article.all); | 11 | +router.get('/list', article.list); |
12 | router.post('/publish', auth, article.publish); | 12 | router.post('/publish', auth, article.publish); |
13 | 13 | ||
14 | module.exports = router; | 14 | module.exports = router; |
@@ -72,7 +72,22 @@ | @@ -72,7 +72,22 @@ | ||
72 | "message": "获取用户信息成功" | 72 | "message": "获取用户信息成功" |
73 | } | 73 | } |
74 | 74 | ||
75 | -### 四、图片列表 | 75 | +### 四、文章列表 |
76 | +**请求路径** | ||
77 | +> {host}/article/list | ||
78 | + | ||
79 | +**请求方法** | ||
80 | +> POST | ||
81 | + | ||
82 | +**请求参数** | ||
83 | + | ||
84 | +|名称 | 类型 |必填| 描述 | ||
85 | +|------|-------|-----|---- | ||
86 | +|pageNo|string |否|页码 | ||
87 | +|pageSize|string |否|每页条数 | ||
88 | +|orderBy | string |否|排序字段名 | ||
89 | +|order | string |否|排序方向,可以为asc或desc,不得为其它值 | ||
90 | +|popular | string |否|热门图片:true 全部图片:false或不传 | ||
76 | 91 | ||
77 | ### 五、发布文章 | 92 | ### 五、发布文章 |
78 | **请求路径** | 93 | **请求路径** |
@@ -90,6 +105,13 @@ | @@ -90,6 +105,13 @@ | ||
90 | |content | string |是|内容 | 105 | |content | string |是|内容 |
91 | 106 | ||
92 | 107 | ||
108 | +**应答参数** | ||
109 | + | ||
110 | +| 名称 | 描述 | ||
111 | +| -------| ------- | ||
112 | +| id | 文章ID | ||
113 | + | ||
114 | + | ||
93 | ### Request (JSON) | 115 | ### Request (JSON) |
94 | { | 116 | { |
95 | "actId": 1 | 117 | "actId": 1 |
@@ -99,6 +121,9 @@ | @@ -99,6 +121,9 @@ | ||
99 | ### Result | 121 | ### Result |
100 | { | 122 | { |
101 | "code": 200, | 123 | "code": 200, |
124 | + "data": { | ||
125 | + id: 3 | ||
126 | + }, | ||
102 | "message": "文章发表成功" | 127 | "message": "文章发表成功" |
103 | } | 128 | } |
104 | 129 |
-
Please register or login to post a comment