Authored by 陈峰

Merge branch 'feature/platform-basic' of http://git.yoho.cn/fe/yoho-activity-pla…

…tform into feature/platform-basic
... ... @@ -4,6 +4,7 @@
* @date: 2017/6/23
*/
'use strict';
const cors = require('cors');
const express = require('express');
const config = require('./config');
const bluebird = require('bluebird');
... ... @@ -34,7 +35,6 @@ app.use(bodyParser.urlencoded({
}));
app.use(cookieParser());
app.use(global.yoho.httpCtx());
app.use(session({
proxy: true,
resave: false,
... ... @@ -64,6 +64,9 @@ const middleware = require('./middleware');
try {
// 允许跨域
app.use(cors());
// 用户信息
app.use(middleware.user);
... ...
... ... @@ -5,10 +5,16 @@
*/
const ArticleModel = require('../models/article');
const GET_ARTICLES_SUCCESS = '获取文章列表成功';
const ADD_ARTICLE_SUCCESS = '文章发表成功';
const GET_ARTICLES_SUCCESS = '获取文章列表成功';
function all(req, res) {
const article = {
/**
* 所有文章
* @param req
* @param res
*/
all(req, res) {
req.ctx(ArticleModel).allArticles()
.then(result => {
res.json({
... ... @@ -18,9 +24,14 @@ function all(req, res) {
});
});
}
},
function add(req, res) {
/**
* 创建文章
* @param req
* @param res
*/
add(req, res) {
const params = req.body;
req.ctx(ArticleModel).createArticle(params)
... ... @@ -30,9 +41,8 @@ function add(req, res) {
message: ADD_ARTICLE_SUCCESS
});
});
}
module.exports = {
all,
add
}
};
module.exports = article;
... ...
/**
* 短信controller
* @author: leo <qi.li@yoho.cn>
* @date: 2017/06/26
*/
'use strict';
const _ = require('lodash');
const EventEmitter = require('events');
... ... @@ -10,17 +15,14 @@ const ANONYMOUS_USER = '匿名用户';
const CODE_REQUIRED = '请输入校验码';
const GET_USER_INFO_FAILED = '获取用户信息失败';
// const BAD_PASSWORD = '密码格式不正确';
// const PASSWORD_REQUIRED = '请输入密码';
// const PASSWORD_LENGTH_ERROR = '密码6-20位,请重新输入';
/**
const sms = {
/**
* 发送短信验证码
* @param req
* @param res
* @returns {*|boolean}
*/
exports.send = (req, res) => {
send(req, res) {
const em = new EventEmitter();
const area = (req.body.area || '').trim();
const mobile = (req.body.mobile || '').trim();
... ... @@ -59,9 +61,24 @@ exports.send = (req, res) => {
code: 400,
message: '请填写手机号'
});
};
},
/**
* 验证码校验
* @param req
* @param res
*/
check(req, res) {
console.log(req, res);
},
exports.login = (req, res, next) => {
/**
* 验证码登录
* @param req
* @param res
* @param next
*/
login(req, res, next) {
const code = (req.body.code || '').trim();
const area = _.get(req.session, 'smsLogin.area', '');
const mobile = _.get(req.session, 'smsLogin.mobile', '');
... ... @@ -160,4 +177,7 @@ exports.login = (req, res, next) => {
})
.catch(next);
}
};
module.exports = sms;
... ...
... ... @@ -14,5 +14,6 @@ const router = express.Router(); // eslint-disable-line
// SMS 短信
router.post('/sms/login', sms.login);
router.post('/sms/sendCode', sms.send);
router.post('/sms/checkCode', sms.check);
module.exports = router;
... ...
... ... @@ -40,6 +40,7 @@
"connect-memcached": "^0.2.0",
"connect-multiparty": "^2.0.0",
"cookie-parser": "^1.4.3",
"cors": "^2.8.3",
"cssnano": "^3.10.0",
"express": "^4.15.3",
"fast-safe-stringify": "^1.2.0",
... ...
... ... @@ -1599,6 +1599,13 @@ core-util-is@~1.0.0:
version "1.0.2"
resolved "http://npm.yoho.cn/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
cors@^2.8.3:
version "2.8.3"
resolved "http://npm.yoho.cn/cors/-/cors-2.8.3.tgz#4cf78e1d23329a7496b2fc2225b77ca5bb5eb802"
dependencies:
object-assign "^4"
vary "^1"
cosmiconfig@^2.1.0, cosmiconfig@^2.1.1:
version "2.1.3"
resolved "http://npm.yoho.cn/cosmiconfig/-/cosmiconfig-2.1.3.tgz#952771eb0dddc1cb3fa2f6fbe51a522e93b3ee0a"
... ... @@ -4943,7 +4950,7 @@ object-assign@^3.0.0:
version "3.0.0"
resolved "http://npm.yoho.cn/object-assign/-/object-assign-3.0.0.tgz#9bedd5ca0897949bca47e7ff408062d549f587f2"
object-assign@^4.0.1, object-assign@^4.1.0:
object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.0:
version "4.1.1"
resolved "http://npm.yoho.cn/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
... ... @@ -7869,7 +7876,7 @@ validate-npm-package-name@^3.0.0, validate-npm-package-name@~3.0.0:
dependencies:
builtins "^1.0.3"
vary@~1.1.0, vary@~1.1.1:
vary@^1, vary@~1.1.0, vary@~1.1.1:
version "1.1.1"
resolved "http://npm.yoho.cn/vary/-/vary-1.1.1.tgz#67535ebb694c1d52257457984665323f587e8d37"
... ...