Merge branch 'feature/platform-basic' of git.yoho.cn:fe/yoho-activity-platform i…
…nto feature/platform-basic
Showing
7 changed files
with
30 additions
and
17 deletions
@@ -3,6 +3,8 @@ | @@ -3,6 +3,8 @@ | ||
3 | * @author: leo <qi.li@yoho.cn> | 3 | * @author: leo <qi.li@yoho.cn> |
4 | * @date: 23/06/2017 | 4 | * @date: 23/06/2017 |
5 | */ | 5 | */ |
6 | +const _ = require('lodash'); | ||
7 | +const camelcase = require('camelcase'); | ||
6 | const ArticleModel = require('../models/article'); | 8 | const ArticleModel = require('../models/article'); |
7 | 9 | ||
8 | const ADD_ARTICLE_SUCCESS = '文章发表成功'; | 10 | const ADD_ARTICLE_SUCCESS = '文章发表成功'; |
@@ -59,11 +61,22 @@ const article = { | @@ -59,11 +61,22 @@ const article = { | ||
59 | pageSize | 61 | pageSize |
60 | }) | 62 | }) |
61 | .then(result => { | 63 | .then(result => { |
64 | + let list = []; | ||
65 | + | ||
66 | + _.each(result, item => { | ||
67 | + let data = {}; | ||
68 | + | ||
69 | + _.each(item, (val, key) => { | ||
70 | + data[camelcase(key)] = val; | ||
71 | + }); | ||
72 | + list.push(data); | ||
73 | + }); | ||
74 | + | ||
62 | req.ctx(ArticleModel).allArticlesNum(actId) | 75 | req.ctx(ArticleModel).allArticlesNum(actId) |
63 | .then(totalCount => { | 76 | .then(totalCount => { |
64 | res.json({ | 77 | res.json({ |
65 | code: 200, | 78 | code: 200, |
66 | - data: result, | 79 | + data: list, |
67 | pageNo, | 80 | pageNo, |
68 | pageSize, | 81 | pageSize, |
69 | totalCount, | 82 | totalCount, |
@@ -105,7 +118,6 @@ const article = { | @@ -105,7 +118,6 @@ const article = { | ||
105 | 118 | ||
106 | req.ctx(ArticleModel).createArticle(params) | 119 | req.ctx(ArticleModel).createArticle(params) |
107 | .then((id) => { | 120 | .then((id) => { |
108 | - | ||
109 | req.ctx(ArticleModel).insertArticleImg(id, imgUrl) | 121 | req.ctx(ArticleModel).insertArticleImg(id, imgUrl) |
110 | .then(() => { | 122 | .then(() => { |
111 | res.json({ | 123 | res.json({ |
@@ -36,8 +36,12 @@ class ArticleModel extends global.yoho.BaseModel { | @@ -36,8 +36,12 @@ class ArticleModel extends global.yoho.BaseModel { | ||
36 | limitSql = `LIMIT ${(pageNo - 1) * pageSize}, ${pageSize}`; | 36 | limitSql = `LIMIT ${(pageNo - 1) * pageSize}, ${pageSize}`; |
37 | 37 | ||
38 | return mysqlCli.query( | 38 | return mysqlCli.query( |
39 | - `SELECT AA.id, AA.good_count goodCount, | ||
40 | - AAI.img_url imgUrl, AA.content, DATE_FORMAT(AA.create_time, '%Y-%m-%d %H:%i:%S') createTime | 39 | + `SELECT |
40 | + AA.id, | ||
41 | + AA.good_count, | ||
42 | + AAI.img_url, | ||
43 | + AA.content, | ||
44 | + AA.create_time | ||
41 | FROM ${TABLE_ACT_ARTICLE} AS AA | 45 | FROM ${TABLE_ACT_ARTICLE} AS AA |
42 | INNER JOIN ${TABLE_ACT_ARTICLE_IMG} AS AAI | 46 | INNER JOIN ${TABLE_ACT_ARTICLE_IMG} AS AAI |
43 | ON AA.id = AAI.article_id | 47 | ON AA.id = AAI.article_id |
@@ -92,6 +92,7 @@ const smsController = { | @@ -92,6 +92,7 @@ const smsController = { | ||
92 | * 验证码校验 | 92 | * 验证码校验 |
93 | * @param req | 93 | * @param req |
94 | * @param res | 94 | * @param res |
95 | + * @param next | ||
95 | */ | 96 | */ |
96 | checkCode(req, res, next) { | 97 | checkCode(req, res, next) { |
97 | const code = (req.body.code + '' || '').trim(); | 98 | const code = (req.body.code + '' || '').trim(); |
@@ -29,16 +29,10 @@ module.exports = { | @@ -29,16 +29,10 @@ module.exports = { | ||
29 | assetUrl: '//127.0.0.1:5001', | 29 | assetUrl: '//127.0.0.1:5001', |
30 | testCode: 'yoho4946abcdef#$%&!@', | 30 | testCode: 'yoho4946abcdef#$%&!@', |
31 | domains: domains, | 31 | domains: domains, |
32 | - subDomains: { | ||
33 | - host: '.m.yohobuy.com', | ||
34 | - default: '//m.yohobuy.com', | ||
35 | - guang: '//guang.m.yohobuy.com', | ||
36 | - list: '//list.m.yohobuy.com', | ||
37 | - search: '//search.m.yohobuy.com', | ||
38 | - huodong: '//huodong.m.yohobuy.com', | ||
39 | - activity: '//activity.yohobuy.com', | ||
40 | - index: '//m.yohobuy.com' | ||
41 | - }, | 32 | + corsAllowOrigin: [ |
33 | + 'http://localhost:8081', | ||
34 | + 'http://localhost:63342' | ||
35 | + ], | ||
42 | useCache: false, | 36 | useCache: false, |
43 | memcache: { | 37 | memcache: { |
44 | master: ['127.0.0.1:11211'], | 38 | master: ['127.0.0.1:11211'], |
@@ -131,6 +125,7 @@ if (isProduction) { | @@ -131,6 +125,7 @@ if (isProduction) { | ||
131 | imCs: 'https://imhttp.yohobuy.com/api', | 125 | imCs: 'https://imhttp.yohobuy.com/api', |
132 | platformApi: 'http://api.platform.yohoops.org' | 126 | platformApi: 'http://api.platform.yohoops.org' |
133 | }, | 127 | }, |
128 | + corsAllowOrigin: ['http://ad.yoho.cn', 'https://ad.yoho.cn'], | ||
134 | memcache: { | 129 | memcache: { |
135 | master: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'], | 130 | master: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'], |
136 | slave: ['memcache1.yohoops.org:12112', 'memcache2.yohoops.org:12112', 'memcache3.yohoops.org:12112'], | 131 | slave: ['memcache1.yohoops.org:12112', 'memcache2.yohoops.org:12112', 'memcache3.yohoops.org:12112'], |
@@ -10,8 +10,8 @@ | @@ -10,8 +10,8 @@ | ||
10 | 10 | ||
11 | **请求参数** | 11 | **请求参数** |
12 | 12 | ||
13 | -| 名称 | 类型 | 描述 | 备注 | aaa | ||
14 | -| ---- | ----- |---- | --- | --- | 13 | +| 名称 | 类型 | 描述 | 备注 | |
14 | +| ---- | ----- |---- | --- | | ||
15 | | mobile|string|手机号| | 15 | | mobile|string|手机号| |
16 | | area | string|区域码| 默认:86 | 16 | | area | string|区域码| 默认:86 |
17 | 17 |
@@ -33,6 +33,7 @@ | @@ -33,6 +33,7 @@ | ||
33 | "dependencies": { | 33 | "dependencies": { |
34 | "bluebird": "^3.4.7", | 34 | "bluebird": "^3.4.7", |
35 | "body-parser": "^1.17.2", | 35 | "body-parser": "^1.17.2", |
36 | + "camelcase": "^4.1.0", | ||
36 | "captchapng": "0.0.1", | 37 | "captchapng": "0.0.1", |
37 | "cheerio": "^0.22.0", | 38 | "cheerio": "^0.22.0", |
38 | "compression": "^1.6.2", | 39 | "compression": "^1.6.2", |
-
Please register or login to post a comment