/**清单编辑器清单库操作相关
 * Created by Zhong on 2017/8/2.
 */
let billsController = require("./bills_lib_controllers");
import baseController from "../../common/base/base_controller";
import CompilationModel from "../../users/models/compilation_model";

let callback = function(req, res, err, message, data){
    res.json({error: err, message: message, data: data});
}
class billsLibPermContr extends baseController{
    async getCompilationList(req, res){
        try{
            let compilationModel = new CompilationModel(), rst = [];
            let compilationList = await compilationModel.getCompilationList();
            if(compilationList.length <= 0){
                throw '没有数据';
            }
            else{

                compilationList.forEach(function (compilation) {
                    rst.push({_id: compilation._id, name: compilation.name});
                })
                callback(req, res, false, '', rst);
            }
        }
        catch(err) {
            callback(req, res, err, '没有数据', null);
        }
    }
    getMaxNumber(req, res){
        billsController.getMaxNumber(req, res);
    }
    getABillsLib(req, res){
        billsController.getABillsLib(req, res);
    }
    getStdBillsLib(req, res){
        billsController.getStdBillsLib(req, res);
    }
    createStdBillsLib(req, res){
        billsController.createStdBillsLib(req, res);
    }
    deleteStdBillsLib(req, res){
        billsController.deleteStdBillsLib(req, res);
    }
    renameStdBillsLib(req, res){
        billsController.renameStdBillsLib(req, res);
    }
    getStdBillsLibName(req, res){
        billsController.getStdBillsLibName(req, res);
    }

}

export default billsLibPermContr;

