/**
 * Created by jimiz on 2017/4/9.
 */
let info_price_facade = require('../facade/info_price_facade');

let logger = require("../../../logs/log_helper").logger;
let controller = {
    getOptions:async function (req){
        let data = req.body.data;
        data = JSON.parse(data);
        return await info_price_facade.getOptions(data,req.session.sessionCompilation);
    },
    getDataByCondition:async function (req){
      let data = req.body.data;
      data = JSON.parse(data);
      return await info_price_facade.getDataByCondition(data,req.session.sessionCompilation);
    },
    getClassByAreaID:async function (req){
        let data = req.body.data;
        data = JSON.parse(data);
        return await info_price_facade.getClassByAreaID(data,req.session.sessionCompilation);
    },
    mutiApplyInfoPrice:async function (req){
      let data = req.body.data;
      data = JSON.parse(data);
      return await info_price_facade.mutiApplyInfoPrice(data,req.session.sessionCompilation);
    }
};

module.exports = {
    action:async function(req,res){//自动跳转到URL对应的controller方法
        let result={
            error:0
        }
        try {
            let functionName = req.url.replace(/\//g,"");
            result.data = controller[functionName]?await controller[functionName](req):"";
        }catch (err){
            logger.err(err.stack);
            result.error=1;
            result.message = err.message;
        }
        res.json(result);
    }
};




