/**
 * Created by Tony on 2017/6/1.
 */

var TplNode = require('../models/tpl_tree_node');

//统一回调函数
var callback = function(req, res, err, data){
    if(err){
        //res.send({success: false, error: err});
        res.json({success: false, error: err});
    }
    else{
        //res.send({success: true, data: data});
        res.json({success:true, data: data});
    }
};

module.exports = {
    createTplTreeNode: function(req, res){
        var lastNodeId = req.body.lastNodeId;
        var nodeData = JSON.parse(req.body.rawNodeData);
        TplNode.createTplTreeNode(nodeData, lastNodeId, function(err, data){
            callback(req,res,err,"", data);
        })
    }
}