Authored by 郝肖肖

'店铺sitemap-mip'

... ... @@ -123,11 +123,13 @@ try {
app.get('/h5/sitemap/hot_:id.xml', sitemap.hotsXmlDataH5);
app.get('/h5/sitemap/chanpin_:id.xml', sitemap.chanpinXmlDataH5);
app.get('/h5/sitemap/productindex.xml', sitemap.productIndexXmlDataH5);
app.get('/h5/sitemap/mip/shop_:id.xml', sitemap.shopMipXmlDataH5);
app.get('/h5/sitemap/mip/list_:id.xml', sitemap.listMipXmlDataH5);
} catch (e) {
logger.error(e);
}
app.listen(config.port, function() {
logger.info(`yoho seo start : http://127.0.0.1:${config.port}`);
});
... ...
... ... @@ -263,6 +263,37 @@ function productIndexXmlDataH5(req, res, next) {
.catch(next);
}
// mip
function shopMipXmlDataH5(req, res, next) {
let page = +req.params.id || 1;
if (page <= 0) {
page = 1;
}
req.ctx(SiteMapServiceH5).shopMipXml(page)
.then(xml => {
res.header('Content-Type', 'application/xml');
res.send(xml);
})
.catch(next);
}
function listMipXmlDataH5(req, res, next) {
let page = +req.params.id || 1;
if (page <= 0) {
page = 1;
}
req.ctx(SiteMapServiceH5).listXml(page)
.then(xml => {
res.header('Content-Type', 'application/xml');
res.send(xml);
})
.catch(next);
}
module.exports = {
indexXmlData,
homeXmlData,
... ... @@ -284,5 +315,8 @@ module.exports = {
chanpinXmlDataH5,
hotsXmlDataH5,
indexJsonDataH5,
productIndexXmlDataH5
productIndexXmlDataH5,
shopMipXmlDataH5,
listMipXmlDataH5
};
... ...
... ... @@ -8,7 +8,11 @@ const BRAND_TYPE = {
shop: 2
};
function getShopUrl(domain, shopId) {
function getShopUrl(domain, shopId, mip) {
if (mip) {
return `/mip/shop/${domain}-${shopId}.html`;
}
return `/shop/${domain}-${shopId}.html`;
}
... ... @@ -22,7 +26,7 @@ module.exports = class extends global.yoho.BaseModel {
this.shopModel = new ShopModel(ctx);
}
async _getShopUrl() {
async _getShopUrl(isMip) {
let shopUrls = [];
await Promise.map(Object.values(CHANNELS), async (channel) => {
... ... @@ -35,7 +39,7 @@ module.exports = class extends global.yoho.BaseModel {
let shopId = shop.shop_id;
let domain = shop.brand_domain || 'default_domain';
shopUrls.push(getShopUrl(domain.toLowerCase(), shopId));
shopUrls.push(getShopUrl(domain.toLowerCase(), shopId, isMip));
}
});
});
... ... @@ -48,6 +52,10 @@ module.exports = class extends global.yoho.BaseModel {
return this._getShopUrl();
}
async getMipUrls() {
return this._getShopUrl(true);
}
async getIndex(type) {
return [indexUrl(type, 1)];
}
... ...
... ... @@ -93,10 +93,12 @@ module.exports = function() {
guang: {
urls: ['/guang/',
'/guang/boys-t0/', '/guang/boys-t1001/', '/guang/boys-t2/', '/guang/boys-t4/', '/guang/boys-t22/', '/guang/news/',
'/guang/girls-t0/', '/guang/girls-t1001/', '/guang/girls-t2/', '/guang/girls-t4', '/guang/girls-t22/',
'/guang/kids-t0/', '/guang/kids-t1001/', '/guang/kids-t2/', '/guang/kids-t4/', '/guang/kids-t22/',
'/guang/lifestyle-t0/', '/guang/lifestyle-t1001/', '/guang/lifestyle-t2/', '/guang/lifestyle-t4/', '/guang/lifestyle-t22/'
'/guang/boys-t0/', '/guang/boys-t1001/', '/guang/boys-t2/', '/guang/boys-t4/',
'/guang/boys-t22/', '/guang/news/', '/guang/girls-t0/', '/guang/girls-t1001/',
'/guang/girls-t2/', '/guang/girls-t4', '/guang/girls-t22/', '/guang/kids-t0/',
'/guang/kids-t1001/', '/guang/kids-t2/', '/guang/kids-t4/', '/guang/kids-t22/',
'/guang/lifestyle-t0/', '/guang/lifestyle-t1001/', '/guang/lifestyle-t2/',
'/guang/lifestyle-t4/', '/guang/lifestyle-t22/'
],
lastmod: today,
priority: PRIO.L1,
... ... @@ -120,4 +122,4 @@ module.exports = function() {
mobile: true
}
};
};
\ No newline at end of file
};
... ...
... ... @@ -137,6 +137,16 @@ module.exports = class extends global.yoho.BaseModel {
return _createXml(this.host, shopConfig.urls, opt);
}
async shopMipXml() {
const shopConfig = this.config.shop;
const opt = _.pick(this.config.shop, this.props);
let urls = await this.shopService.getMipUrls();
shopConfig.urls = shopConfig.urls.concat(urls);
return _createXml(this.host, shopConfig.urls, opt);
}
async productXml(page) {
const productConfig = this.config.product;
const opt = _.pick(this.config.product, this.props);
... ...
... ... @@ -18,20 +18,20 @@ module.exports = {
cookieDomain: '.yohobuy.com',
domains: {
// test3
// singleApi: 'http://api-test3.yohops.com:9999/',
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://api-test3.yohops.com:9999/',
// serviceNotify: 'http://api-test3.yohops.com:9999/',
// global: 'http://global-test-soa.yohops.com:9999/',
// platformApi: 'http://192.168.102.48:8088/',
// yohoNowApi: 'http://yohonow-test.yohops.com:9999/'
api: 'http://api-test3.dev.yohocorp.com/',
service: 'http://api-test3.dev.yohocorp.com/',
singleApi: 'http://api-test3.dev.yohocorp.com/',
serviceNotify: 'http://api-test3.dev.yohocorp.com/',
global: 'http://global-test-soa.yohops.com:9999/',
platformApi: 'http://192.168.102.48:8088/',
yohoNowApi: 'http://yohonow-test.yohops.com:9999/'
// prod
singleApi: 'http://single.yoho.cn/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
serviceNotify: 'http://service.yoho.cn/',
global: 'http://api-global.yohobuy.com/'
// singleApi: 'http://single.yoho.cn/',
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// serviceNotify: 'http://service.yoho.cn/',
// global: 'http://api-global.yohobuy.com/'
// gray
// singleApi: 'http://single.gray.yohops.com/',
... ...