Authored by 郝肖肖

Merge branch 'feature/libxml-xsd'

1 const xsd = require('libxml-xsd'); 1 const xsd = require('libxml-xsd');
2 const fs = require('fs'); 2 const fs = require('fs');
3 -const xml = './public/dist/goods-xml/goods-1.xml';  
4 -const xmlFile = fs.readFileSync(xml).toString();  
5 -  
6 -xsd.parseFile('./apps/controllers/seo/xm.xsd', function(err1, schema) {  
7 - console.log(err1, schema);  
8 - schema.validate(xmlFile, function(err, validationErrors) {  
9 - console.log(err);  
10 - console.log(validationErrors);  
11 - });  
12 -}); 3 +const xsdFile = fs.readFileSync('./apps/controllers/seo/xm.xsd').toString();
  4 +
  5 +
  6 +for (let i = 1; i <= 32; i++) {
  7 + const xml = `./public/dist/goods-xml/goods-${i}.xml`;
  8 + const xmlFile = fs.readFileSync(xml).toString();
  9 + const schema = xsd.parse(xsdFile);
  10 + const validationErrors = schema.validate(xmlFile);
13 11
  12 + console.log(`check => start: ${i} `);
  13 +
  14 + validationErrors && validationErrors.forEach(verr => {
  15 + console.log(i, verr.line, verr.str1);
  16 + });
  17 +}
@@ -194,8 +194,8 @@ const baiduBrand = { @@ -194,8 +194,8 @@ const baiduBrand = {
194 yoho: '袜子', 194 yoho: '袜子',
195 categoryLv1: '服饰内衣', 195 categoryLv1: '服饰内衣',
196 categoryLv2: '内衣', 196 categoryLv2: '内衣',
197 - categoryLv3: '休闲棉袜',  
198 - categoryLv4: '休闲棉袜' 197 + categoryLv3: '休闲棉袜 ',
  198 + categoryLv4: '休闲棉袜 '
199 }, 199 },
200 147: { 200 147: {
201 yoho: '休闲/运动鞋', 201 yoho: '休闲/运动鞋',
@@ -964,8 +964,8 @@ const baiduBrand = { @@ -964,8 +964,8 @@ const baiduBrand = {
964 yoho: '袜子', 964 yoho: '袜子',
965 categoryLv1: '服饰内衣', 965 categoryLv1: '服饰内衣',
966 categoryLv2: '内衣', 966 categoryLv2: '内衣',
967 - categoryLv3: '休闲棉袜',  
968 - categoryLv4: '休闲棉袜' 967 + categoryLv3: '休闲棉袜 ',
  968 + categoryLv4: '休闲棉袜 '
969 }, 969 },
970 411: { 970 411: {
971 yoho: '手拎包/单肩包', 971 yoho: '手拎包/单肩包',
@@ -1025,10 +1025,10 @@ const baiduBrand = { @@ -1025,10 +1025,10 @@ const baiduBrand = {
1025 }, 1025 },
1026 486: { 1026 486: {
1027 yoho: '灯具', 1027 yoho: '灯具',
1028 - categoryLv1: '家用电器',  
1029 - categoryLv2: '五金家装',  
1030 - categoryLv3: '灯具',  
1031 - categoryLv4: '灯具' 1028 + categoryLv1: '家装建材',
  1029 + categoryLv2: '灯饰照明',
  1030 + categoryLv3: 'LED灯',
  1031 + categoryLv4: ''
1032 }, 1032 },
1033 488: { 1033 488: {
1034 yoho: '打火机', 1034 yoho: '打火机',
@@ -1179,9 +1179,9 @@ const baiduBrand = { @@ -1179,9 +1179,9 @@ const baiduBrand = {
1179 }, 1179 },
1180 1218: { 1180 1218: {
1181 yoho: 'GoPro', 1181 yoho: 'GoPro',
1182 - categoryLv1: '',  
1183 - categoryLv2: '',  
1184 - categoryLv3: '', 1182 + categoryLv1: '数码',
  1183 + categoryLv2: '摄影摄像',
  1184 + categoryLv3: '运动相机',
1185 categoryLv4: '' 1185 categoryLv4: ''
1186 }, 1186 },
1187 1220: { 1187 1220: {
@@ -1298,37 +1298,37 @@ const baiduBrand = { @@ -1298,37 +1298,37 @@ const baiduBrand = {
1298 }, 1298 },
1299 1254: { 1299 1254: {
1300 yoho: '安全避孕', 1300 yoho: '安全避孕',
1301 - categoryLv1: '',  
1302 - categoryLv2: '',  
1303 - categoryLv3: '', 1301 + categoryLv1: '医药保健',
  1302 + categoryLv2: '计生情趣',
  1303 + categoryLv3: '安全避孕',
1304 categoryLv4: '' 1304 categoryLv4: ''
1305 }, 1305 },
1306 1256: { 1306 1256: {
1307 yoho: '情爱玩具', 1307 yoho: '情爱玩具',
1308 - categoryLv1: '',  
1309 - categoryLv2: '',  
1310 - categoryLv3: '', 1308 + categoryLv1: '医药保健',
  1309 + categoryLv2: '计生情趣',
  1310 + categoryLv3: '女用器具',
1311 categoryLv4: '' 1311 categoryLv4: ''
1312 }, 1312 },
1313 1258: { 1313 1258: {
1314 yoho: '人体润滑', 1314 yoho: '人体润滑',
1315 - categoryLv1: '',  
1316 - categoryLv2: '',  
1317 - categoryLv3: '', 1315 + categoryLv1: '医药保健',
  1316 + categoryLv2: '计生情趣',
  1317 + categoryLv3: '人体润滑',
1318 categoryLv4: '' 1318 categoryLv4: ''
1319 }, 1319 },
1320 1260: { 1320 1260: {
1321 yoho: '验孕测孕', 1321 yoho: '验孕测孕',
1322 - categoryLv1: '',  
1323 - categoryLv2: '',  
1324 - categoryLv3: '', 1322 + categoryLv1: '医药保健',
  1323 + categoryLv2: '计生情趣',
  1324 + categoryLv3: '验孕测孕',
1325 categoryLv4: '' 1325 categoryLv4: ''
1326 }, 1326 },
1327 1262: { 1327 1262: {
1328 yoho: 'SM用品', 1328 yoho: 'SM用品',
1329 - categoryLv1: '',  
1330 - categoryLv2: '',  
1331 - categoryLv3: '', 1329 + categoryLv1: '医药保健',
  1330 + categoryLv2: '计生情趣',
  1331 + categoryLv3: '人体润滑',
1332 categoryLv4: '' 1332 categoryLv4: ''
1333 }, 1333 },
1334 1264: { 1334 1264: {
@@ -1419,8 +1419,8 @@ const baiduBrand = { @@ -1419,8 +1419,8 @@ const baiduBrand = {
1419 yoho: '电子秤/厨房秤', 1419 yoho: '电子秤/厨房秤',
1420 categoryLv1: '家用电器', 1420 categoryLv1: '家用电器',
1421 categoryLv2: '个护健康', 1421 categoryLv2: '个护健康',
1422 - categoryLv3: '电子秤/厨房秤',  
1423 - categoryLv4: '电子秤' 1422 + categoryLv3: '电子秤',
  1423 + categoryLv4: ''
1424 }, 1424 },
1425 1292: { 1425 1292: {
1426 yoho: '血糖仪', 1426 yoho: '血糖仪',
@@ -1438,9 +1438,9 @@ const baiduBrand = { @@ -1438,9 +1438,9 @@ const baiduBrand = {
1438 }, 1438 },
1439 1296: { 1439 1296: {
1440 yoho: '温度计', 1440 yoho: '温度计',
1441 - categoryLv1: '',  
1442 - categoryLv2: '',  
1443 - categoryLv3: '', 1441 + categoryLv1: '医药保健',
  1442 + categoryLv2: '保健器械',
  1443 + categoryLv3: '体温计',
1444 categoryLv4: '' 1444 categoryLv4: ''
1445 }, 1445 },
1446 1298: { 1446 1298: {
@@ -1452,10 +1452,10 @@ const baiduBrand = { @@ -1452,10 +1452,10 @@ const baiduBrand = {
1452 }, 1452 },
1453 1300: { 1453 1300: {
1454 yoho: '电子血压计', 1454 yoho: '电子血压计',
1455 - categoryLv1: '家用电器',  
1456 - categoryLv2: '个护健康', 1455 + categoryLv1: '医药保健',
  1456 + categoryLv2: '保健器械',
1457 categoryLv3: '血压计', 1457 categoryLv3: '血压计',
1458 - categoryLv4: '血压计' 1458 + categoryLv4: ''
1459 }, 1459 },
1460 1302: { 1460 1302: {
1461 yoho: '智能眼镜', 1461 yoho: '智能眼镜',
@@ -2216,9 +2216,9 @@ const baiduBrand = { @@ -2216,9 +2216,9 @@ const baiduBrand = {
2216 1532: { 2216 1532: {
2217 yoho: '图书/杂志', 2217 yoho: '图书/杂志',
2218 categoryLv1: '图书', 2218 categoryLv1: '图书',
2219 - categoryLv2: '图书',  
2220 - categoryLv3: '图书',  
2221 - categoryLv4: '图书' 2219 + categoryLv2: '小说',
  2220 + categoryLv3: '期刊杂志',
  2221 + categoryLv4: ''
2222 }, 2222 },
2223 1534: { 2223 1534: {
2224 yoho: '纹身贴', 2224 yoho: '纹身贴',
@@ -2565,10 +2565,10 @@ const baiduBrand = { @@ -2565,10 +2565,10 @@ const baiduBrand = {
2565 }, 2565 },
2566 1650: { 2566 1650: {
2567 yoho: '灯具', 2567 yoho: '灯具',
2568 - categoryLv1: '家用电器',  
2569 - categoryLv2: '五金家装',  
2570 - categoryLv3: '灯具',  
2571 - categoryLv4: '灯具' 2568 + categoryLv1: '家装建材',
  2569 + categoryLv2: '灯饰照明',
  2570 + categoryLv3: 'LED灯',
  2571 + categoryLv4: ''
2572 }, 2572 },
2573 1652: { 2573 1652: {
2574 yoho: '唇部护理', 2574 yoho: '唇部护理',
@@ -2810,16 +2810,16 @@ const baiduBrand = { @@ -2810,16 +2810,16 @@ const baiduBrand = {
2810 }, 2810 },
2811 1726: { 2811 1726: {
2812 yoho: '宠物主粮', 2812 yoho: '宠物主粮',
2813 - categoryLv1: '',  
2814 - categoryLv2: '',  
2815 - categoryLv3: '', 2813 + categoryLv1: '宠物生活',
  2814 + categoryLv2: '宠物主粮',
  2815 + categoryLv3: '狗粮',
2816 categoryLv4: '' 2816 categoryLv4: ''
2817 }, 2817 },
2818 1728: { 2818 1728: {
2819 yoho: '宠物零食', 2819 yoho: '宠物零食',
2820 - categoryLv1: '',  
2821 - categoryLv2: '',  
2822 - categoryLv3: '', 2820 + categoryLv1: '宠物生活',
  2821 + categoryLv2: '宠物主粮',
  2822 + categoryLv3: '狗粮',
2823 categoryLv4: '' 2823 categoryLv4: ''
2824 }, 2824 },
2825 1730: { 2825 1730: {
@@ -3343,7 +3343,7 @@ const baiduBrand = { @@ -3343,7 +3343,7 @@ const baiduBrand = {
3343 1902: { 3343 1902: {
3344 yoho: '毛衣', 3344 yoho: '毛衣',
3345 categoryLv1: '服饰内衣', 3345 categoryLv1: '服饰内衣',
3346 - categoryLv2: '装', 3346 + categoryLv2: '装',
3347 categoryLv3: '羊毛衫', 3347 categoryLv3: '羊毛衫',
3348 categoryLv4: '羊毛衫' 3348 categoryLv4: '羊毛衫'
3349 }, 3349 },
@@ -59,7 +59,7 @@ class SeoIndexModel extends global.yoho.BaseModel { @@ -59,7 +59,7 @@ class SeoIndexModel extends global.yoho.BaseModel {
59 _.each(productLists, item => { 59 _.each(productLists, item => {
60 let images = []; 60 let images = [];
61 61
62 - if (!baiduBrand[item.small_sort_id]) { 62 + if (!baiduBrand[item.small_sort_id] || !baiduBrand[item.small_sort_id].categoryLv1) {
63 console.error(`goods-xml => s_sort_id: ${item.small_sort_id}, s_sort_name: ${item.small_sort_name}, baidu cate is null`);// eslint-disable-line 63 console.error(`goods-xml => s_sort_id: ${item.small_sort_id}, s_sort_name: ${item.small_sort_name}, baidu cate is null`);// eslint-disable-line
64 return true; 64 return true;
65 } 65 }