...
|
...
|
@@ -10,8 +10,9 @@ const Router = require('koa-router'); |
|
|
const moment = require('moment');
|
|
|
const pager = require('../utils/pager');
|
|
|
const Mysql = require('../../../lib/mysql-promise');
|
|
|
|
|
|
const Promise = require('bluebird');
|
|
|
const r = new Router();
|
|
|
const rp = require('request-promise');
|
|
|
|
|
|
const multiAsync=(multi)=>{
|
|
|
return multi.execAsync().then(function(res) {
|
...
|
...
|
@@ -157,16 +158,33 @@ r.get('/searchKeywords', async(ctx) => { |
|
|
};
|
|
|
});
|
|
|
|
|
|
const insertWord = (keyword, mysql) => {
|
|
|
return mysql.query(`SELECT id FROM seo_keywords WHERE keyword = ?`, [keyword]).then(d => {
|
|
|
if (d.length <= 0) {
|
|
|
return mysql.query(
|
|
|
`INSERT INTO seo_keywords SET keyword = ?, is_push = ?, yoho_goods_num= ?, add_time = ?`,
|
|
|
[keyword, 1, -2, Date.now()]
|
|
|
);
|
|
|
}
|
|
|
return d;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
r.get('/syncWord', async(ctx) => {
|
|
|
let mysql = new Mysql();
|
|
|
|
|
|
let r = await mysql.query(`select * from seo_keywords`);
|
|
|
console.log(r[0].keyword, ' ===');
|
|
|
ctx.body = {
|
|
|
code: 200,
|
|
|
message: 'success',
|
|
|
data: r
|
|
|
};
|
|
|
return getDataList(ctx, "keywords_mana_list", 0, 1).then(d => {
|
|
|
return getDataValues(ctx, d[0]);
|
|
|
}).then(ddata => {
|
|
|
return Promise.map(ddata, (word) => insertWord(word, mysql), {concurrency: 15});
|
|
|
}).then(d => {
|
|
|
return ctx.body = {
|
|
|
code: 200,
|
|
|
message: 'success',
|
|
|
data: d
|
|
|
};
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
module.exports = r; |
...
|
...
|
|