/**
 * Created by jimiz on 2017/4/9.
 */
var rationData = require('../models/ration');

//统一回调函数
var callback = function(req, res, err, message, data){
    res.json({error: err, message: message, data: data});
};

module.exports = {
    getData: function(req, res){
        var data = JSON.parse(req.body.data);
        rationData.getData(data.projectId, function(err, message, rationList){
            if (err === 0) {
                callback(req, res, err, message, rationList);
            } else {
                callback(req, res, err, message, null);
            }
        });
    },

    getItemTemplate: function(req, res){
        //var data = JSON.parse(req.body.data);
        rationData.getItemTemplate(function(err, message, rationItem){
            if (billsItem) {
                callback(req, res, err, message, rationItem);
            } else {
                callback(req, res, err, message, null);
            }
        });
    },

    allocIDs: function(req, res){
        rationData.allocIDs(function(err, message, data){
            if (err) {
                callback(req, res, err, message, data);
            } else {
                callback(req, res, err, message, null);
            }
        });
    }

};