/**
 * Created by Tony on 2017/3/24.
 */
var cache = require('../../../public/cache/cacheUtil');
var cmn_ctrl = require('../models/cfg_control');
var cmn_font = require('../models/cfg_font');
var cmn_style = require('../models/cfg_style');

const RPT_CFG_GRP = 'rpt_cfg';

module.exports = {
    setReportDefaultCache: function () {
        cmn_ctrl.getAll(null, function(err, ctrls){
            if (ctrls) {
                cache.setCache(RPT_CFG_GRP,'common_ctrls',ctrls);
            }
        });
        cmn_font.getAll(null, function(err, fonts){
            if (fonts) {
                cache.setCache(RPT_CFG_GRP,'common_fonts',fonts);
            }
        });
        cmn_style.getAll(null, function(err, styles){
            if (styles) {
                cache.setCache(RPT_CFG_GRP,'common_styles',styles);
            }
        });
    },
    getReportDefaultCache: function () {
        var rst = {ctrls: null, fonts: null, styles: null};
        rst.ctrls = cache.getCache(RPT_CFG_GRP,'common_ctrls');
        rst.fonts = cache.getCache(RPT_CFG_GRP,'common_fonts');
        rst.styles = cache.getCache(RPT_CFG_GRP,'common_styles');
        return rst;
    }
}
