/**
 * Created by zhang on 2018/9/12.
 */

let divideFacade = require('../facade/divide_facade');
let logger = require("../../../logs/log_helper").logger;
let controller = {
    updateItem:async function(req) {
        let data = req.body.data;
        return await divideFacade.updateItem(JSON.parse(data));
    },
    updateCoeAdjust:async function(req){
      let data = req.body.data;
      return await divideFacade.updateCoeAdjust(JSON.parse(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);
            result.error=1;
            result.message = err.message;
        }
        res.json(result);
    }
};