...
|
...
|
@@ -5,13 +5,10 @@ const Promise = require('bluebird'); |
|
|
const _ = require('lodash');
|
|
|
const sm = require('sitemap');
|
|
|
const staticUrls = require('../../../config/staticUrls');
|
|
|
const api = global.yoho.API;
|
|
|
const Service = global.yoho.ServiceAPI;
|
|
|
const headerModel = require('../../../doraemon/models/header');
|
|
|
const siteMapService = require('../models/site-map-service');
|
|
|
const redis = global.yoho.redis;
|
|
|
|
|
|
|
|
|
const getStaticUrls = (currentStatics) => {
|
|
|
let urls = [];
|
|
|
|
...
|
...
|
@@ -57,10 +54,10 @@ const keywordsPage = (page) => { |
|
|
};
|
|
|
|
|
|
// 逛详情
|
|
|
const getArticleUrls = () => {
|
|
|
const getArticleUrls = (req) => {
|
|
|
let urls = [];
|
|
|
|
|
|
return Service.get('/guang/api/v2/article/getLastArticleList', {limit: 1000}, {cache: 86400}).then(res => {
|
|
|
return req.ctx(siteMapService).guangArticles().then(res => {
|
|
|
|
|
|
_.forEach(_.get(res, 'data.artList', ''), val => {
|
|
|
urls.push({
|
...
|
...
|
@@ -75,13 +72,13 @@ const getArticleUrls = () => { |
|
|
};
|
|
|
|
|
|
// www 地图数据
|
|
|
const wwwXmlData = (page) => {// eslint-disable-line
|
|
|
const wwwXmlData = (req, page) => {// eslint-disable-line
|
|
|
if (page > 1) {
|
|
|
return keywordsPage(page);
|
|
|
} else {
|
|
|
return Promise.all([keywordsPage(page),
|
|
|
getStaticUrls(_.get(staticUrls, 'www')),
|
|
|
getArticleUrls()]).then(result => {
|
|
|
getArticleUrls(req)]).then(result => {
|
|
|
return _.concat(result[1], result[0], result[2]);
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -113,10 +110,10 @@ const listXmlData = () => {// eslint-disable-line |
|
|
};
|
|
|
|
|
|
// item 地图数据
|
|
|
const itemXmlData = () => {// eslint-disable-line
|
|
|
const itemXmlData = (req) => {// eslint-disable-line
|
|
|
let urls = [];
|
|
|
|
|
|
return api.get('', {method: 'web.product.bdPromotion'}, {cache: 86400}).then(res => {
|
|
|
return req.ctx(siteMapService).itemList().then(res => {
|
|
|
_.forEach(_.get(res, 'data', ''), val => {
|
|
|
urls.push({
|
|
|
url: `https:${helpers.getUrlBySkc(val.erpProductId)}`,
|
...
|
...
|
@@ -142,7 +139,7 @@ const siteMap = (req, res, next) => { |
|
|
|
|
|
let page = req.params[0] || 1;
|
|
|
|
|
|
eval(subdomain + 'XmlData')(page).then(urls => {// eslint-disable-line
|
|
|
eval(subdomain + 'XmlData')(req, page).then(urls => {// eslint-disable-line
|
|
|
sm.createSitemap({
|
|
|
hostname: `https://${subdomain}.yohobuy.com`,
|
|
|
xmlNs: ' ',
|
...
|
...
|
|