/**
 * Created by CSL on 2018-12-17.
 */

let mongoose = require('mongoose');
let blFacade = require('../facade/block_lib_facade');

module.exports = {
    doController: async function (req, res) {
        let result = {error: 0, message: '', data: null};
        try {
            let funcName = req.url.replace(/\//g, "");
            let dataObj = JSON.parse(req.body.data);
            result.data = await blFacade[funcName](dataObj);
        } catch (err) {
            console.log(err);
            result.error = 1;
            result.message = err.message;
        }
        res.json(result);
    }
};

