site-map-service.js 1.71 KB
/**
 * map
 * @author: xiaoxiao<xiaoxiao.hao@yoho.cn>
 * @date: 2017/10/24
 */
'use strict';

const _ = require('lodash');

module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    guangList(page, lres) {
        return this.get({
            url: 'guang/api/v2/article/getList',
            data: {
                page: page,
                limit: 1000
            },
            param: {
                cache: true
            },
            api: global.yoho.ServiceAPI
        }).then(rdata => {
            let artList = _.get(rdata, 'data.list.artList', []);

            if (artList.length <= 0) {
                return lres;
            }

            lres = lres.concat(_.map(artList, (art) => {
                return art.id;
            }));

            rdata = [];
            artList = [];

            return this.guangList(++page, lres);
        });
    }

    newsList(page, lres) {
        return this.get({
            url: 'yohonow/api/page/getPolymerizationList',
            data: {
                type: 'wechat',
                limit: 100,
                id: 'yohobuy4008899646,yohogroup,YOHO_GIRL,mars-app',
                page: page
            },
            param: {
                cache: true
            },
            api: global.yoho.YohoNowApi
        }).then(rdata => {
            let artList = _.get(rdata, 'data.content', []);

            if (artList.length <= 0) {
                return lres;
            }

            lres = lres.concat(_.map(artList, (art) => {
                return `${art.id}_${art.cid}`;
            }));

            rdata = [];
            artList = [];

            return this.newsList(++page, lres);
        });
    }

};