Authored by 陈峰

commit

... ... @@ -5,6 +5,7 @@
"plugins": [
"transform-runtime",
"transform-object-rest-spread",
"transform-async-to-generator",
"syntax-dynamic-import"
]
}
... ...
{
"parser": "babel-eslint",
"extends": "yoho",
"parserOptions": {
"sourceType": "module"
... ...
... ... @@ -653,7 +653,71 @@ const article = {
}, (result) => {
return res.json(result);
}).catch(next);
}
},
/**
* Y100文章列表
* @param req
* @param res
* @param next
*/
async y100List(req, res, next) {
const {actId, pageNo = 1, pageSize = 10, tag = ''} = req.query;
if (!actId) {
return res.json({
code: 400,
message: INVALID_PARAMS
});
}
try {
const result = await req.ctx(ArticleModel).articleY100List({
actId,
pageNo,
pageSize,
tag
});
return res.json({
code: 200,
data: result,
pageNo: +pageNo,
pageSize: +pageSize,
message: GET_SUCCESS
});
} catch (err) {
return next(err);
}
},
/**
* Y100详情
* @param req
* @param res
* @param next
*/
async y100Detail(req, res, next) {
const {id} = req.query;
if (!id) {
return res.json({
code: 400,
message: INVALID_PARAMS
});
}
try {
const result = await req.ctx(ArticleModel).articleY100Detail(id);
return res.json({
code: 200,
data: result,
});
} catch (err) {
return next(err);
}
},
};
... ...
... ... @@ -9,6 +9,7 @@ const mysqlCli = global.yoho.utils.mysqlCli;
const TABLE_USER = 'user';
const TABLE_ACT_ARTICLE = 'act_article';
const TABLE_ACT_ARTICLE_Y100 = 'act_article_y100';
const TABLE_ACT_ARTICLE_IMG = 'act_article_img';
const TABLE_ACT_ARTICLE_GOOD = 'act_article_good';
... ... @@ -473,6 +474,89 @@ class ArticleModel extends global.yoho.BaseModel {
}
);
}
/**
* 获取Y100列表
* @returns {*}
*/
articleY100List({actId, pageNo, pageSize, tag}) {
const params = {
actId,
start: (pageNo - 1) * pageSize,
page: _.parseInt(pageSize)
};
let sql = `
SELECT
AA.id,
AA.good_count,
AA.create_time,
AAY.name,
AAY.img_url
FROM ${TABLE_ACT_ARTICLE} AA
INNER JOIN ${TABLE_ACT_ARTICLE_Y100} AAY ON AA.id = AAY.article_id
WHERE AA.act_id = :actId`;
if (tag) {
sql += ' and AAY.tag like :tag';
params.tag = `%${tag}%`;
}
sql += ' ORDER BY AA.good_count DESC';
sql += ' LIMIT :start, :page';
return mysqlCli.query(sql, params);
}
/**
* 获取Y100详情
* @returns {*}
*/
async articleY100Detail(id) {
let sql = `
SELECT
AAY.id,
AAY.act_id,
AAY.article_id,
AAY.img_url,
AAY.tag,
AAY.name,
AAY.career,
AAY.style,
AAY.interest,
AAY.skns,
AAY.create_time
FROM ${TABLE_ACT_ARTICLE_Y100} AAY
where AAY.id = :id`;
const query = await mysqlCli.query(sql, {
id
});
if (query.length === 1) {
const result = query[0];
const {skns} = query[0];
if (skns) {
const productsResult = await this.get({
data: {
method: 'h5.product.batch',
limit: skns.split(',').length,
productSkn: skns,
contain_all: 'Y'
},
param: {
cache: true
}
});
if (productsResult.code === 200 && productsResult.data) {
result.products = productsResult.data.product_list;
}
}
return result;
}
}
}
module.exports = ArticleModel;
... ...
... ... @@ -10,6 +10,8 @@ const article = require('./controllers/article');
router.post('/like', article.like);
router.get('/list', article.list);
router.get('/y100list', article.y100List);
router.get('/y100detail', article.y100Detail);
router.get('/listNoImg', article.listNoImg);
router.get('/listNoUser', article.listNoUser);
router.post('/publish', auth, article.publish);
... ...
... ... @@ -17,9 +17,15 @@ module.exports = {
siteUrl: '//action.yoho.cn',
assetUrl: `/yoho-activity-platform/${pkg.version}/`,
domains: {
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/'
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
// singleApi: 'http://api-test3.yohops.com:9999/'
singleApi: 'http://api.yoho.cn/',
api: 'http://api.yoho.cn/',
service: 'http://api.yoho.cn/',
serviceNotify: 'http://service.yoho.cn/',
platformApi: 'http://172.16.6.210:8088/',
},
corsAllowOrigin: [
'http://localhost:8081',
... ...
... ... @@ -4,3 +4,18 @@
@date: 2018-03-14 14:56:16
*/
#注意:GO;分割执行块
#y100活动文章扩展
CREATE TABLE IF NOT EXISTS act_article_y100 (
`id` int(8) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`act_id` int(8) NOT NULL DEFAULT 0,
`article_id` int(8) NOT NULL DEFAULT 0,
`img_url` varchar(200) DEFAULT '',
`tag` varchar(200) DEFAULT '',
`name` varchar(200) DEFAULT '',
`career` varchar(200) DEFAULT '',
`style` varchar(200) DEFAULT '',
`interest` varchar(200) DEFAULT '',
`skns` varchar(1000) DEFAULT '',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) DEFAULT CHARSET=utf8;
... ...
... ... @@ -77,7 +77,7 @@
"whatwg-fetch": "^2.0.3",
"xlsx": "^0.11.16",
"yoho-md5": "^2.0.0",
"yoho-node-lib": "=0.2.28",
"yoho-node-lib": "^0.6.3",
"yoho-zookeeper": "^1.0.8"
},
"devDependencies": {
... ... @@ -87,6 +87,7 @@
"babel-loader": "^6.2.10",
"babel-plugin-istanbul": "^3.1.2",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-preset-env": "^1.2.1",
... ...
... ... @@ -290,7 +290,7 @@ arrify@^1.0.0, arrify@^1.0.1:
version "1.0.1"
resolved "http://npm.yohops.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"
asap@^2.0.0:
asap@^2.0.0, asap@~2.0.3:
version "2.0.6"
resolved "http://npm.yohops.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
... ... @@ -625,7 +625,7 @@ babel-plugin-syntax-trailing-function-commas@^6.22.0:
version "6.22.0"
resolved "http://npm.yohops.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3"
babel-plugin-transform-async-to-generator@^6.22.0:
babel-plugin-transform-async-to-generator@^6.22.0, babel-plugin-transform-async-to-generator@^6.24.1:
version "6.24.1"
resolved "http://npm.yohops.com/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761"
dependencies:
... ... @@ -1046,7 +1046,7 @@ block-stream@*:
dependencies:
inherits "~2.0.0"
bluebird@3.x.x, bluebird@^3.0.5, bluebird@^3.0.6, bluebird@^3.1.1, bluebird@^3.3, bluebird@^3.4.0, bluebird@^3.4.7, bluebird@^3.5.0, bluebird@^3.5.1, bluebird@~3.5.1:
bluebird@3.x.x, bluebird@^3.0.5, bluebird@^3.0.6, bluebird@^3.1.1, bluebird@^3.4.7, bluebird@^3.5.0, bluebird@^3.5.1, bluebird@~3.5.1:
version "3.5.1"
resolved "http://npm.yohops.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9"
... ... @@ -2318,13 +2318,13 @@ debug@2, debug@2.6.9, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.3.3, de
dependencies:
ms "2.0.0"
debug@3.1.0, debug@^3.0.0, debug@^3.1.0:
debug@3.1.0, debug@^3.0.0, debug@^3.0.1, debug@^3.1.0:
version "3.1.0"
resolved "http://npm.yohops.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
dependencies:
ms "2.0.0"
debuglog@*, debuglog@^1.0.1:
debuglog@^1.0.1:
version "1.0.1"
resolved "http://npm.yohops.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
... ... @@ -2511,6 +2511,13 @@ dns-txt@^2.0.2:
dependencies:
buffer-indexof "^1.0.0"
dnscache@^1.0.1:
version "1.0.1"
resolved "http://npm.yohops.com/dnscache/-/dnscache-1.0.1.tgz#42cb2b9bfb5e8fbdfa395aac74e127fc05074d31"
dependencies:
asap "~2.0.3"
lodash.clone "~4.3.2"
doctrine@^2.0.0:
version "2.1.0"
resolved "http://npm.yohops.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d"
... ... @@ -4377,7 +4384,7 @@ import-local@^1.0.0:
pkg-dir "^2.0.0"
resolve-cwd "^2.0.0"
imurmurhash@*, imurmurhash@^0.1.4:
imurmurhash@^0.1.4:
version "0.1.4"
resolved "http://npm.yohops.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
... ... @@ -4410,6 +4417,14 @@ inflight@^1.0.4, inflight@~1.0.6:
once "^1.3.0"
wrappy "1"
influx-batch-sender@^0.1.5:
version "0.1.5"
resolved "http://npm.yohops.com/influx-batch-sender/-/influx-batch-sender-0.1.5.tgz#865a5eb9a446f4e8ed442ab44e67c3532c27a5d7"
dependencies:
debug "^3.0.1"
lodash "^4.17.4"
request "^2.83.0"
inherits@1:
version "1.0.2"
resolved "http://npm.yohops.com/inherits/-/inherits-1.0.2.tgz#ca4309dadee6b54cc0b8d247e8d7c7a0975bdc9b"
... ... @@ -5237,6 +5252,10 @@ lodash._basecallback@^3.0.0:
lodash.isarray "^3.0.0"
lodash.pairs "^3.0.0"
lodash._baseclone@~4.5.0:
version "4.5.7"
resolved "http://npm.yohops.com/lodash._baseclone/-/lodash._baseclone-4.5.7.tgz#ce42ade08384ef5d62fa77c30f61a46e686f8434"
lodash._basecopy@^3.0.0:
version "3.0.1"
resolved "http://npm.yohops.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36"
... ... @@ -5251,10 +5270,6 @@ lodash._baseget@^3.0.0:
version "3.7.2"
resolved "http://npm.yohops.com/lodash._baseget/-/lodash._baseget-3.7.2.tgz#1b6ae1d5facf3c25532350a13c1197cb8bb674f4"
lodash._baseindexof@*:
version "3.1.0"
resolved "http://npm.yohops.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
lodash._baseisequal@^3.0.0:
version "3.0.7"
resolved "http://npm.yohops.com/lodash._baseisequal/-/lodash._baseisequal-3.0.7.tgz#d8025f76339d29342767dcc887ce5cb95a5b51f1"
... ... @@ -5278,25 +5293,15 @@ lodash._basevalues@^3.0.0:
version "3.0.0"
resolved "http://npm.yohops.com/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz#5b775762802bde3d3297503e26300820fdf661b7"
lodash._bindcallback@*, lodash._bindcallback@^3.0.0:
lodash._bindcallback@^3.0.0:
version "3.0.1"
resolved "http://npm.yohops.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
lodash._cacheindexof@*:
version "3.0.2"
resolved "http://npm.yohops.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
lodash._createcache@*:
version "3.1.2"
resolved "http://npm.yohops.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
dependencies:
lodash._getnative "^3.0.0"
lodash._createset@~4.0.0:
version "4.0.3"
resolved "http://npm.yohops.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
lodash._getnative@*, lodash._getnative@^3.0.0:
lodash._getnative@^3.0.0:
version "3.9.1"
resolved "http://npm.yohops.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
... ... @@ -5342,6 +5347,12 @@ lodash.camelcase@^4.3.0:
version "4.3.0"
resolved "http://npm.yohops.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"
lodash.clone@~4.3.2:
version "4.3.2"
resolved "http://npm.yohops.com/lodash.clone/-/lodash.clone-4.3.2.tgz#e56b176b6823a7dde38f7f2bf58de7d5971200e9"
dependencies:
lodash._baseclone "~4.5.0"
lodash.clonedeep@^4.3.2, lodash.clonedeep@~4.5.0:
version "4.5.0"
resolved "http://npm.yohops.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
... ... @@ -5445,7 +5456,7 @@ lodash.reject@^4.4.0:
version "4.6.0"
resolved "http://npm.yohops.com/lodash.reject/-/lodash.reject-4.6.0.tgz#80d6492dc1470864bbf583533b651f42a9f52415"
lodash.restparam@*, lodash.restparam@^3.0.0:
lodash.restparam@^3.0.0:
version "3.6.1"
resolved "http://npm.yohops.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
... ... @@ -5490,7 +5501,7 @@ lodash@^3.10.1:
version "3.10.1"
resolved "http://npm.yohops.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
lodash@^4.0.0, lodash@^4.1.0, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.6.1, lodash@~4.17.4:
lodash@^4.0.0, lodash@^4.1.0, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.3.0, lodash@~4.17.4:
version "4.17.5"
resolved "http://npm.yohops.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511"
... ... @@ -7010,6 +7021,10 @@ phantomjs-prebuilt@^2.1.14:
request-progress "^2.0.1"
which "^1.2.10"
pidusage@^1.1.6:
version "1.2.0"
resolved "http://npm.yohops.com/pidusage/-/pidusage-1.2.0.tgz#65ee96ace4e08a4cd3f9240996c85b367171ee92"
pify@^2.0.0, pify@^2.3.0:
version "2.3.0"
resolved "http://npm.yohops.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
... ... @@ -8184,7 +8199,7 @@ readable-stream@~2.0.0:
string_decoder "~0.10.x"
util-deprecate "~1.0.1"
readdir-scoped-modules@*, readdir-scoped-modules@^1.0.0:
readdir-scoped-modules@^1.0.0:
version "1.0.2"
resolved "http://npm.yohops.com/readdir-scoped-modules/-/readdir-scoped-modules-1.0.2.tgz#9fafa37d286be5d92cbaebdee030dc9b5f406747"
dependencies:
... ... @@ -8403,14 +8418,6 @@ request-promise-core@1.1.1:
dependencies:
lodash "^4.13.1"
request-promise@^3.0.0:
version "3.0.0"
resolved "http://npm.yohops.com/request-promise/-/request-promise-3.0.0.tgz#be1edb26f41c49cd1d5656c6753d6842a1249f46"
dependencies:
bluebird "^3.3"
lodash "^4.6.1"
request "^2.34"
request-promise@^4.2.1:
version "4.2.2"
resolved "http://npm.yohops.com/request-promise/-/request-promise-4.2.2.tgz#d1ea46d654a6ee4f8ee6a4fea1018c22911904b4"
... ... @@ -8420,7 +8427,7 @@ request-promise@^4.2.1:
stealthy-require "^1.1.0"
tough-cookie ">=2.3.3"
request@2, request@^2.34, request@^2.44.0, request@^2.54.0, request@^2.74.0, request@^2.81.0, request@~2.83.0:
request@2, request@^2.44.0, request@^2.54.0, request@^2.74.0, request@^2.81.0, request@~2.83.0:
version "2.83.0"
resolved "http://npm.yohops.com/request/-/request-2.83.0.tgz#ca0b65da02ed62935887808e6f510381034e3356"
dependencies:
... ... @@ -8474,6 +8481,33 @@ request@2.81.0:
tunnel-agent "^0.6.0"
uuid "^3.0.0"
request@^2.83.0:
version "2.85.0"
resolved "http://npm.yohops.com/request/-/request-2.85.0.tgz#5a03615a47c61420b3eb99b7dba204f83603e1fa"
dependencies:
aws-sign2 "~0.7.0"
aws4 "^1.6.0"
caseless "~0.12.0"
combined-stream "~1.0.5"
extend "~3.0.1"
forever-agent "~0.6.1"
form-data "~2.3.1"
har-validator "~5.0.3"
hawk "~6.0.2"
http-signature "~1.2.0"
is-typedarray "~1.0.0"
isstream "~0.1.2"
json-stringify-safe "~5.0.1"
mime-types "~2.1.17"
oauth-sign "~0.8.2"
performance-now "^2.1.0"
qs "~6.5.1"
safe-buffer "^5.1.1"
stringstream "~0.0.5"
tough-cookie "~2.3.3"
tunnel-agent "^0.6.0"
uuid "^3.1.0"
request@~2.79.0:
version "2.79.0"
resolved "http://npm.yohops.com/request/-/request-2.79.0.tgz#4dfe5bf6be8b8cdc37fcf93e04b65577722710de"
... ... @@ -10144,7 +10178,7 @@ v8flags@^2.0.2:
dependencies:
user-home "^1.1.1"
validate-npm-package-license@*, validate-npm-package-license@^3.0.1:
validate-npm-package-license@^3.0.1:
version "3.0.1"
resolved "http://npm.yohops.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc"
dependencies:
... ... @@ -10509,7 +10543,7 @@ winston-daily-rotate-file@^1.1.1:
dependencies:
mkdirp "0.5.1"
winston@^2.2.0, winston@^2.3.1:
winston@^2.3.1:
version "2.4.0"
resolved "http://npm.yohops.com/winston/-/winston-2.4.0.tgz#808050b93d52661ed9fb6c26b3f0c826708b0aee"
dependencies:
... ... @@ -10520,6 +10554,17 @@ winston@^2.2.0, winston@^2.3.1:
isstream "0.1.x"
stack-trace "0.0.x"
winston@^2.4.0:
version "2.4.1"
resolved "http://npm.yohops.com/winston/-/winston-2.4.1.tgz#a3a9265105564263c6785b4583b8c8aca26fded6"
dependencies:
async "~1.0.0"
colors "1.0.x"
cycle "1.0.x"
eyes "0.1.x"
isstream "0.1.x"
stack-trace "0.0.x"
wordwrap@0.0.2:
version "0.0.2"
resolved "http://npm.yohops.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f"
... ... @@ -10791,21 +10836,23 @@ yoho-mlellipsis@0.0.3:
version "0.0.3"
resolved "http://npm.yohops.com/yoho-mlellipsis/-/yoho-mlellipsis-0.0.3.tgz#5f743eeb74ff6f2df58a802cff7cd8ad8e4b21f4"
yoho-node-lib@=0.2.28:
version "0.2.28"
resolved "http://npm.yohops.com/yoho-node-lib/-/yoho-node-lib-0.2.28.tgz#32fa27778bf231106c690e89550f6ab83941ffd0"
yoho-node-lib@^0.6.3:
version "0.6.3"
resolved "http://npm.yohops.com/yoho-node-lib/-/yoho-node-lib-0.6.3.tgz#d17a18a07127a961169746fe4391483542591f9b"
dependencies:
bluebird "^3.4.0"
dnscache "^1.0.1"
handlebars "^4.0.5"
influx-batch-sender "^0.1.5"
lodash "^4.13.1"
lru-cache "^4.1.1"
md5 "^2.1.0"
memcached "^2.2.2"
memory-cache "^0.1.6"
moment "^2.13.0"
request-promise "^3.0.0"
pidusage "^1.1.6"
request "^2.81.0"
uuid "^3.0.1"
walk "^2.3.9"
winston "^2.2.0"
winston "^2.4.0"
winston-daily-rotate-file "^1.1.1"
xss-filters "^1.2.6"
... ...