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

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

const QUESTION_CODE = '1337a9f26f3972060bb2a2ca3aba81fd';

const suggestFeedBack = () => {
    return api.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;
    });
};

module.exports = {
    suggestFeedBack
};