|
@@ -4,30 +4,34 @@
|
|
|
|
|
|
var mongoose = require("mongoose");
|
|
|
var dbm = require("../../../config/db/db_manager");
|
|
|
+var chapterTreeDb = dbm.getCfgConnection("rationRepository")
|
|
|
var async = require("async");
|
|
|
var Schema = mongoose.Schema;
|
|
|
|
|
|
var rationChapterTreeSchema = mongoose.Schema({//章节树 //生成唯一id改为sectionID 改成string
|
|
|
+ rationRepId: Number,
|
|
|
sectionId:Number,
|
|
|
parentId:Number,
|
|
|
nextSiblingId:Number,
|
|
|
name:String
|
|
|
});
|
|
|
-
|
|
|
+var rationChapterTreeModel = chapterTreeDb.model("rationChapterTrees",rationChapterTreeSchema, "rationChapterTrees")
|
|
|
+var repositoryMap = require('./repositoryMap');
|
|
|
|
|
|
var rationChapterTreeDAO = function(){};
|
|
|
|
|
|
-rationChapterTreeDAO.prototype.getRationChapterTrees = function(repositoryDbName,callback){
|
|
|
- var db = dbm.getCfgConnection(repositoryDbName)
|
|
|
- var rationChapterTreeModel = db.model("rationChapterTrees",rationChapterTreeSchema, "rationChapterTrees")
|
|
|
- rationChapterTreeModel.find({},function(err,data){
|
|
|
- if(data.length) callback(false,data);
|
|
|
- else if(err) callback("获取定额树错误!",false)
|
|
|
- else callback(false,false);
|
|
|
+rationChapterTreeDAO.prototype.getRationChapterTrees = function(repositoryName,callback){
|
|
|
+ repositoryMap.getRealLibName(repositoryName, function(err, rst){
|
|
|
+ rationChapterTreeModel.find({"rationRepId": rst[0].ID},function(err,data){
|
|
|
+ if(data.length) callback(false,data);
|
|
|
+ else if(err) callback("获取定额树错误!",false)
|
|
|
+ else callback(false,false);
|
|
|
+ })
|
|
|
})
|
|
|
}
|
|
|
-rationChapterTreeDAO.prototype.tempRationChapterTreeInsert = function(repositoryDbName,rationTempTree,callback){
|
|
|
- var db = dbm.getCfgConnection(repositoryDbName)
|
|
|
+
|
|
|
+rationChapterTreeDAO.prototype.tempRationChapterTreeInsert = function(repositoryName,rationTempTree,callback){
|
|
|
+ var db = dbm.getCfgConnection(repositoryName)
|
|
|
var rationChapterTreeModel = db.model("rationChapterTrees",rationChapterTreeSchema, "rationChapterTrees")
|
|
|
rationChapterTreeModel.collection.insert(rationTempTree,function(err,data){
|
|
|
if(err) callback("插入定额模板错误",false)
|
|
@@ -35,8 +39,8 @@ rationChapterTreeDAO.prototype.tempRationChapterTreeInsert = function(repository
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-rationChapterTreeDAO.prototype.sectionUpsert = function(repositoryDbName,section,callback){
|
|
|
- var db = dbm.getCfgConnection(repositoryDbName);
|
|
|
+rationChapterTreeDAO.prototype.sectionUpsert = function(repositoryName,section,callback){
|
|
|
+ var db = dbm.getCfgConnection(repositoryName);
|
|
|
var rationChapterTreeModel = db.model("rationChapterTrees",rationChapterTreeSchema, "rationChapterTrees");
|
|
|
rationChapterTreeModel.find({"sectionId": section.sectionId},function(err,data){
|
|
|
if(data.length){
|
|
@@ -57,8 +61,8 @@ rationChapterTreeDAO.prototype.sectionUpsert = function(repositoryDbName,section
|
|
|
})
|
|
|
}
|
|
|
//待 ration模块完成
|
|
|
-rationChapterTreeDAO.prototype.deleteSection= function(repositoryDbName,sectionId,callback){
|
|
|
- var db = dbm.getCfgConnection(repositoryDbName);
|
|
|
+rationChapterTreeDAO.prototype.deleteSection= function(repositoryName,sectionId,callback){
|
|
|
+ var db = dbm.getCfgConnection(repositoryName);
|
|
|
var rationChapterTreeModel = db.model("rationItems",rationChapterTreeSchema);
|
|
|
rationChapterTreeModel.find({"sectionId": sectionId},[],function(err,data){
|
|
|
|