/**
 * Created by vian on 2017/3/22.
 */

var billsLibDao = require("./../models/bills_lib_interfaces");
//----
var model = require("./../models/bills_lib_model");
var counter = require("../../../public/counter/counter");
var StdBillsLib = model.stdBillsLibMod;
var Bills = model.billsMod;
var JobContent = model.jobContentMod;
var ItemCharacter = model.itemCharacterMod;
//---
//ͳһ�ص�����
var callback = function(req, res, err, message, data){
    res.json({error: err, message: message, data: data});
}

module.exports = {
    getMaxNumber: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.getMaxNumber(data, function(err, message, maxNumber){
            callback(req, res, err, message, maxNumber);
        });
    },
    getABillsLib: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.getABillsLib(data, function(err, message, data){
            callback(req, res, err, message, data);
        });
    },
    getStdBillsLib: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.getStdBillsLib(data, function(err, message, stdBillsLib){
            callback(req, res, err, message, stdBillsLib );
        });
    },
    createStdBillsLib: function(req, res){
        var data = JSON.parse(req.body.data);
         billsLibDao.createStdBillsLib(data, function(err, message, info){
            callback(req, res, err, message, info);
         });
    },
    deleteStdBillsLib: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.deleteStdBillsLib(data.billsLibId, function(err, message){
            callback(req, res, err, message, null);
        });
    },
    renameStdBillsLib: function(req, res) {
        var data = JSON.parse(req.body.data);
        billsLibDao.renameStdBillsLib(data, function (err, message) {
            callback(req, res, err ,message, null);
        });
    },
    getStdBillsLibName: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.getStdBillsLibName(data.billsLibId, function(err, message, info){
            callback(req, res, err, message, info);
        });
    },
    getBills: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.getBills(data.billsLibId, function(err, message, bills){
            callback(req, res, err, message, bills);
        });
    },
    createBills: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.createBills(data, function(err, message){
            callback(req, res, err, message, null);
        });
    },
    updatePNId: function (req, res) {
        var data = JSON.parse(req.body.data);
        billsLibDao.updatePNId(data, function(err, message){
            callback(req, res, err, message, null);
        });
    },
    updateBills: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.updateBills(data, function(err, message){
            callback(req, res, err, message, null);
        });
    },
    updateBillsArr: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.updateBillsArr(data, function(err, message){
           callback(req, res, err, message, null);
        });
    },
    pasteBills: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.pasteBills(data, function(err, message){
            callback(req, res, err, message, null);
        });
    },
    updateRecharge: function(req, res){
      var data = JSON.parse(req.body.data);
        billsLibDao.updateRecharge(data, function(err, message){
            callback(req, res, err, message, null);
        });
    },
    deleteBills: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.deleteBills(data, function(err, message){
            callback(req, res, err, message, null);
        });
    },
    getJobContent: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.getJobContent(data, function(err, message, jobs){
            callback(req, res, err, message, jobs);
        });
    },
    createJobContent: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.createJobContent(data, function(err, message, id){
            callback(req, res, err, message, id);
        });
    },
    updateJobContent: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.updateJobContent(data, function(err, message, id){
            callback(req, res, err, message, id);
        });
    },
    updateValue: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.updateValue(data, function(err, message){
            callback(req, res, err, message, null);
        })
    },
    deleteJobContent: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.deleteJobContent(data, function(err, message){
            callback(req, res, err, message, null);
        });
    },
    getItemCharacter: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.getItemCharacter(data, function(err, message, items){
            callback(req, res, err, message, items);
        });
    },
    createItemCharacter: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.createItemCharacter(data, function(err, message, id){
            callback(req, res, err, message, id);
        });
    },
    updateItemCharacter: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.updateItemCharacter(data, function(err, message){
            callback(req, res, err, message, null);
        });
    },
    deleteItemCharacter: function(req, res){
        var data = JSON.parse(req.body.data);
        billsLibDao.deleteItemCharacter(data, function(err, message){
            callback(req, res, err, message, null);
        });
    }

}

