Authored by 李奇

字段格式化

... ... @@ -55,7 +55,7 @@ try {
// 允许跨域
app.use(cors({
credentials: true,
origin: 'http://localhost:63342'
origin: config.corsAllowOrigin
}));
// 用户信息
... ...
... ... @@ -3,6 +3,8 @@
* @author: leo <qi.li@yoho.cn>
* @date: 23/06/2017
*/
const _ = require('lodash');
const camelcase = require('camelcase');
const ArticleModel = require('../models/article');
const ADD_ARTICLE_SUCCESS = '文章发表成功';
... ... @@ -59,11 +61,22 @@ const article = {
pageSize
})
.then(result => {
let list = [];
_.each(result, item => {
let data = {};
_.each(item, (val, key) => {
data[camelcase(key)] = val;
});
list.push(data);
});
req.ctx(ArticleModel).allArticlesNum(actId)
.then(totalCount => {
res.json({
code: 200,
data: result,
data: list,
pageNo,
pageSize,
totalCount,
... ... @@ -105,7 +118,6 @@ const article = {
req.ctx(ArticleModel).createArticle(params)
.then((id) => {
req.ctx(ArticleModel).insertArticleImg(id, imgUrl)
.then(() => {
res.json({
... ...
... ... @@ -36,8 +36,12 @@ class ArticleModel extends global.yoho.BaseModel {
limitSql = `LIMIT ${(pageNo - 1) * pageSize}, ${pageSize}`;
return mysqlCli.query(
`SELECT AA.id, AA.good_count goodCount,
AAI.img_url imgUrl, AA.content, DATE_FORMAT(AA.create_time, '%Y-%m-%d %H:%i:%S') createTime
`SELECT
AA.id,
AA.good_count,
AAI.img_url,
AA.content,
AA.create_time
FROM ${TABLE_ACT_ARTICLE} AS AA
INNER JOIN ${TABLE_ACT_ARTICLE_IMG} AS AAI
ON AA.id = AAI.article_id
... ...
... ... @@ -92,6 +92,7 @@ const smsController = {
* 验证码校验
* @param req
* @param res
* @param next
*/
checkCode(req, res, next) {
const code = (req.body.code + '' || '').trim();
... ...
... ... @@ -29,16 +29,10 @@ module.exports = {
assetUrl: '//127.0.0.1:5001',
testCode: 'yoho4946abcdef#$%&!@',
domains: domains,
subDomains: {
host: '.m.yohobuy.com',
default: '//m.yohobuy.com',
guang: '//guang.m.yohobuy.com',
list: '//list.m.yohobuy.com',
search: '//search.m.yohobuy.com',
huodong: '//huodong.m.yohobuy.com',
activity: '//activity.yohobuy.com',
index: '//m.yohobuy.com'
},
corsAllowOrigin: [
'http://localhost:8081',
'http://localhost:63342'
],
useCache: false,
memcache: {
master: ['127.0.0.1:11211'],
... ... @@ -131,6 +125,7 @@ if (isProduction) {
imCs: 'https://imhttp.yohobuy.com/api',
platformApi: 'http://api.platform.yohoops.org'
},
corsAllowOrigin: ['http://ad.yoho.cn', 'https://ad.yoho.cn'],
memcache: {
master: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'],
slave: ['memcache1.yohoops.org:12112', 'memcache2.yohoops.org:12112', 'memcache3.yohoops.org:12112'],
... ...
... ... @@ -10,8 +10,8 @@
**请求参数**
| 名称 | 类型 | 描述 | 备注 | aaa
| ---- | ----- |---- | --- | ---
| 名称 | 类型 | 描述 | 备注 |
| ---- | ----- |---- | --- |
| mobile|string|手机号|
| area | string|区域码| 默认:86
... ...
... ... @@ -33,6 +33,7 @@
"dependencies": {
"bluebird": "^3.4.7",
"body-parser": "^1.17.2",
"camelcase": "^4.1.0",
"captchapng": "0.0.1",
"cheerio": "^0.22.0",
"compression": "^1.6.2",
... ...