Authored by 李奇

修改文档

@@ -7,15 +7,9 @@ const _ = require('lodash'); @@ -7,15 +7,9 @@ const _ = require('lodash');
7 const camelcase = require('camelcase'); 7 const camelcase = require('camelcase');
8 const ArticleModel = require('../models/article'); 8 const ArticleModel = require('../models/article');
9 9
10 -const ADD_ARTICLE_SUCCESS = '文章发表成功';  
11 -const GET_ARTICLES_SUCCESS = '获取文章列表成功';  
12 -const GET_ARTICLE_SUCCESS = '获取文章详情成功';  
13 -const INVALID_ACTIVITY_ID = '活动ID[actId]不能为空';  
14 -const INVALID_IMG = '图片[imgUrl]不能为空';  
15 -const INVALID_CONTENT = '内容[content]都不能为空';  
16 -const MISS_PARAMS = '缺少参数';  
17 -const INVALID_ORDER = '排序[order]值为asc或desc';  
18 -const INVALID_ORDER_BY = '排序字段[orderBy]非法'; 10 +const POST_SUCCESS = '操作成功';
  11 +const GET_SUCCESS = '获取成功';
  12 +const INVALID_PARAMS = '参数错误';
19 13
20 const article = { 14 const article = {
21 /** 15 /**
@@ -42,14 +36,14 @@ const article = { @@ -42,14 +36,14 @@ const article = {
42 if (order !== 'asc' && order !== 'desc') { 36 if (order !== 'asc' && order !== 'desc') {
43 return res.json({ 37 return res.json({
44 code: 400, 38 code: 400,
45 - message: INVALID_ORDER 39 + message: INVALID_PARAMS
46 }); 40 });
47 } 41 }
48 42
49 if (orderByFields.indexOf(orderBy) === -1) { 43 if (orderByFields.indexOf(orderBy) === -1) {
50 return res.json({ 44 return res.json({
51 code: 400, 45 code: 400,
52 - message: INVALID_ORDER_BY 46 + message: INVALID_PARAMS
53 }); 47 });
54 } 48 }
55 49
@@ -81,7 +75,7 @@ const article = { @@ -81,7 +75,7 @@ const article = {
81 pageSize, 75 pageSize,
82 totalCount, 76 totalCount,
83 totalPage: Math.ceil(totalCount / pageSize), 77 totalPage: Math.ceil(totalCount / pageSize),
84 - message: GET_ARTICLES_SUCCESS 78 + message: GET_SUCCESS
85 }); 79 });
86 }); 80 });
87 }); 81 });
@@ -99,9 +93,9 @@ const article = { @@ -99,9 +93,9 @@ const article = {
99 const imgUrl = req.body.imgUrl; 93 const imgUrl = req.body.imgUrl;
100 const content = req.body.content; 94 const content = req.body.content;
101 95
102 - !imgUrl && (errorMsg = INVALID_IMG);  
103 - !content && (errorMsg = INVALID_CONTENT);  
104 - !actId && (errorMsg = INVALID_ACTIVITY_ID); 96 + if (!imgUrl || !content || !actId) {
  97 + errorMsg = INVALID_PARAMS;
  98 + }
105 99
106 if (errorMsg) { 100 if (errorMsg) {
107 return res.json({ 101 return res.json({
@@ -123,7 +117,7 @@ const article = { @@ -123,7 +117,7 @@ const article = {
123 res.json({ 117 res.json({
124 code: 200, 118 code: 200,
125 data: {id}, 119 data: {id},
126 - message: ADD_ARTICLE_SUCCESS 120 + message: POST_SUCCESS
127 }); 121 });
128 }); 122 });
129 }); 123 });
@@ -139,8 +133,9 @@ const article = { @@ -139,8 +133,9 @@ const article = {
139 const actId = req.query.actId; 133 const actId = req.query.actId;
140 const articleId = req.query.articleId; 134 const articleId = req.query.articleId;
141 135
142 - !actId && (errorMsg = MISS_PARAMS);  
143 - !articleId && (errorMsg = MISS_PARAMS); 136 + if (!actId || !articleId) {
  137 + errorMsg = INVALID_PARAMS;
  138 + }
144 139
145 if (errorMsg) { 140 if (errorMsg) {
146 return res.json({ 141 return res.json({
@@ -154,7 +149,7 @@ const article = { @@ -154,7 +149,7 @@ const article = {
154 res.json({ 149 res.json({
155 code: 200, 150 code: 200,
156 data: ret, 151 data: ret,
157 - message: GET_ARTICLE_SUCCESS 152 + message: GET_SUCCESS
158 }); 153 });
159 }); 154 });
160 }, 155 },
@@ -171,7 +166,7 @@ const article = { @@ -171,7 +166,7 @@ const article = {
171 if (!actId || !articleId) { 166 if (!actId || !articleId) {
172 return res.json({ 167 return res.json({
173 code: 400, 168 code: 400,
174 - message: MISS_PARAMS 169 + message: INVALID_PARAMS
175 }); 170 });
176 } 171 }
177 172
@@ -181,7 +176,7 @@ const article = { @@ -181,7 +176,7 @@ const article = {
181 .then(() => { 176 .then(() => {
182 res.json({ 177 res.json({
183 code: 200, 178 code: 200,
184 - message: '点赞成功' 179 + message: POST_SUCCESS
185 }); 180 });
186 }); 181 });
187 }); 182 });
1 1
2 ## 基础服务 2 ## 基础服务
3 3
4 -## 登录(只支持短信验证登录)  
5 -[验证码登录](http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录)  
6 -  
7 - [发送验证码](http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/发送验证码.md) 4 - [发送验证码](http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/发送验证码.md)
8 - - [手机号自动登录](http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/手机号自动登录.md)  
9 - - [校验是否是注册用户](http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/校验是否是注册用户.md)  
10 - [验证验证码](http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/验证验证码.md) 5 - [验证验证码](http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/个人中心/验证码登录/验证验证码.md)
1 1
2 ### 一、点赞 2 ### 一、点赞
  3 +**请求路径**
  4 +> {host}/article/like
  5 +
  6 +**请求方法**
  7 +> POST
  8 +
  9 +**请求参数**
  10 +
  11 +| 名称 | 类型 | 描述 | 备注 |
  12 +| ---- | ----- |---- | --- |
  13 +| artId|string|活动ID|
  14 +| article | string|文章ID|
3 15
  16 +
  17 +### Request (JSON)
  18 + {
  19 + "actId": 1,
  20 + "articleId": 1
  21 + }
  22 +### Result
  23 + {
  24 + "code": 200,
  25 + "message": "操作成功"
  26 + }
  27 +
4 ### 二、发送验证码 28 ### 二、发送验证码
5 **请求路径** 29 **请求路径**
6 > {host}/passport/sms/sendCOde 30 > {host}/passport/sms/sendCOde
@@ -126,7 +150,7 @@ @@ -126,7 +150,7 @@
126 "pageSize": 10, 150 "pageSize": 10,
127 "totalCount": 21, 151 "totalCount": 21,
128 "totalPage": 3, 152 "totalPage": 3,
129 - "message": "获取文章列表成功" 153 + "message": "获取成功"
130 } 154 }
131 155
132 ### 五、发布文章 156 ### 五、发布文章
@@ -164,7 +188,7 @@ @@ -164,7 +188,7 @@
164 "data": { 188 "data": {
165 id: 3 189 id: 3
166 }, 190 },
167 - "message": "文章发表成功" 191 + "message": "操作成功"
168 } 192 }
169 193
170 194
@@ -207,5 +231,5 @@ @@ -207,5 +231,5 @@
207 "imgUrl": "http://img01.yohoboys.com/o_1bk3gc79c11p21c4l1e4ksk0vdl7.jpg?imageMogr2/auto-orient/thumbnail/626/strip/gravity/Center/quality/60/crop/626x530/format/jpg" 231 "imgUrl": "http://img01.yohoboys.com/o_1bk3gc79c11p21c4l1e4ksk0vdl7.jpg?imageMogr2/auto-orient/thumbnail/626/strip/gravity/Center/quality/60/crop/626x530/format/jpg"
208 } 232 }
209 ], 233 ],
210 - "message": "获取文章详情成功" 234 + "message": "获取成功"
211 } 235 }