Authored by 郝肖肖

Merge branch 'feature/goodsXml'

... ... @@ -145,6 +145,7 @@ public/bundle/*
.DS_Store
.devhost
library
yarn.lock
### foreman ###
... ...
... ... @@ -50,16 +50,6 @@ app.get('/synchronousKeywords', seo.synchronousKeywords);
app.get('/sendKeywordsUrls', seo.sendKeywordsUrls);
app.get('/sendUrls', seo.sendUrls);
// 404错误
app.use(function(req, res) {
return res.status(404).send('');
});
// 500错误
app.use(function(err, req, res) {
return res.status(err.status || 500).send('');
});
app.listen(config.port, function() {
logger.info(`yoho seo start : http://127.0.0.1:${config.port}`);
});
... ...
... ... @@ -2,21 +2,33 @@
const SeoIndexModel = require('../../models/seo/index');
const index = (req, res) => {
return req.ctx(SeoIndexModel).writerGoodsXml(req.params).then(result => {
return res.json(result);
if (global.IS_GOODS_XML_RUN) {
return res.json({code: 201, message: '上一个任务正在运行中...'});
}
global.IS_GOODS_XML_RUN = true;
req.ctx(SeoIndexModel).writerGoodsXml(req.params).then(() => {
global.IS_GOODS_XML_RUN = false;
});
return res.json({
code: 200,
data: `http://spiderwebhook.yoho.cn/dist/goods-xml/goods-${req.params.start || 1}.xml`,
message: '任务创建成功,开始运行...'
});
};
const autoGoodsXml = (req, res) => {
if (global.IS_GOODS_XML_RUN) {
return res.json({code: 201, message: '后台正在运行中...'});
return res.json({code: 201, message: '上一个任务正在运行中...'});
}
global.IS_GOODS_XML_RUN = true;
req.ctx(SeoIndexModel).autoGoodsXml({start: 1});
res.json({code: 200, message: 'success...'});
res.json({code: 200, message: '任务创建成功,开始运行...'});
};
const setTask = (req, res) => {
... ...
... ... @@ -10,6 +10,7 @@ const goodsHbs = require(`${ROOT_PATH}/hbs/partials/seo/index.hbs`);
const util = require(`${ROOT_PATH}/libs/util`);
const redis = require(`${ROOT_PATH}/libs/redis`);
const SIZE = 4000;
const GOODS_URL = 'http://spiderwebhook.yoho.cn/dist/goods-xml';
class SeoIndexModel extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -38,7 +39,8 @@ class SeoIndexModel extends global.yoho.BaseModel {
result = [];
return {code: 200, data: `http://127.0.0.1:6005/dist/goods-xml/${fileName}`};
console.log(`${GOODS_URL}/${fileName} over...`);
return {code: 200, data: `${GOODS_URL}/${fileName}`};
});
}
... ... @@ -63,7 +65,7 @@ class SeoIndexModel extends global.yoho.BaseModel {
_.each(item.goods_list, goods => {
images.push({
contentUrl: helpers.image(goods.images_url, 450, 600),
contentUrl: `https:${helpers.image(goods.images_url, 450, 600)}`,
height: 600,
width: 450,
description: `${item.product_name}-${goods.color_name}`,
... ... @@ -73,7 +75,7 @@ class SeoIndexModel extends global.yoho.BaseModel {
});
products.push({
loc: `http://spiderwebhook.yoho.cn/dist/goods-xml/goods-${params.start}.xml`,
loc: `${GOODS_URL}/goods-${params.start}.xml`,
lastmod: moment.unix(item.edit_time).format('YYYY-MM-DD'),
changefreq: 'weekly',
priority: 1.0,
... ... @@ -138,12 +140,12 @@ class SeoIndexModel extends global.yoho.BaseModel {
searchList(params) {
params = _.assign({
limit: 60,
limit: 100,
method: 'app.search.li',
status: 1,
sales: 'Y',
stocknumber: 1,
method: 'app.search.li',
attribute_not: 2
attribute_not: 2,
udid: 'seo_format_data'
}, params);
return this.get({
... ...
... ... @@ -77,20 +77,15 @@ module.exports = {
maxFiles: 7
},
errorFile: {
close: false,
name: 'error',
level: 'error',
filename: 'logs/error.log',
handleExceptions: true,
maxFiles: 7
},
udp: { // send by udp
measurement: 'yohobuy_node_log',
level: 'debug', // logger level
host: 'influxdblog.web.yohoops.org', // influxdb host
port: '4444' // influxdb port
},
console: {
level: 'info',
level: 'debug',
colorize: 'all',
prettyPrint: true
}
... ...
... ... @@ -11,7 +11,7 @@
<fromSrc>{{fromSrc}}</fromSrc>
{{#images}}
<image>
<contentUrl>{{contentUrl}}</contentUrl>
<contentUrl><![CDATA[{{{contentUrl}}}]]></contentUrl>
<height>{{height}}</height>
<width>{{width}}</width>
<description>{{description}}</description>
... ...
... ... @@ -32,7 +32,7 @@
"winston": "^2.3.1",
"winston-daily-rotate-file": "^1.1.1",
"yoho-md5": "^2.0.0",
"yoho-node-lib": "^0.2.23"
"yoho-node-lib": "=0.5.29"
},
"devDependencies": {
"eslint": "^2.12.0",
... ...