/*
/!**
 * Created by CSL on 2017-03-22.
 *!/

var mg = require('mongoose');
var dbm = require("../../../config/db/db_manager");
var db = dbm.getCfgConnection("scConstruct");

var ratesSchema = new mg.Schema({
    ID: Number,
    ParentID: Number,
    name: String,
    rate: Number,
    memo: String
});

var libsSchema = new mg.Schema({
    region: String,                     // 工程所在地
    libID: Number,                     // 费率标准文件ID
    libName: String,                   // 费率标准文件名称
    rates: [ratesSchema]                  // 树表结构费率值
});

var libsModel = db.model('std_fee_rate_libs', libsSchema, 'std_fee_rate_libs');

var StdFeeRateLibs = function(){};

StdFeeRateLibs.prototype.libNames = function(region, controllerFun){
    libsModel.find({"region": region}, ["libID", "libName"], function(err, data){
        if(data.length){
            controllerFun(data);
        }
        else{
            controllerFun(false);
        }
    })
};

StdFeeRateLibs.prototype.rates = function(libID, controllerFun){
    libsModel.find({"libID": libID}, ["rates"], function(err, data){
        if(data.length){
            controllerFun(data);
        }
        else{
            controllerFun(false);
        }
    })
};

module.exports = new StdFeeRateLibs();


*/
