suggestFeedBack-service.js 969 Bytes
/**
 * suggestFeedBack model
 * @author: gxh<xuhui.ge@yoho.cn>
 * @date: 2017/05/25
 */
'use strict';

const GetBanner = require('./getBanner');
const _ = require('lodash');

const QUESTION_CODE = '1337a9f26f3972060bb2a2ca3aba81fd';

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

        this.getBanner = new GetBanner(ctx);
    }

    suggestFeedBack() {
        return this.getBanner.getResource(QUESTION_CODE).then(result => {
            if (result.code === 200) {
                let data = _.dropWhile(_.get(result, 'data', []), o => {
                    return o.template_name !== 'single_image'; // 取一张图资源位
                });
                let list = [];

                _.forEach(data, value => {
                    list.push(_.get(value, 'data[0]', ''));
                });

                result.data = _.compact(list);
            }

            return result;
        });
    }
};