|
@@ -17,22 +17,15 @@ var rationChapterTreeSchema = mongoose.Schema({//章节树 //生成唯一id改
|
|
isDeleted: Boolean
|
|
isDeleted: Boolean
|
|
});
|
|
});
|
|
var rationChapterTreeModel = chapterTreeDb.model("rationChapterTrees",rationChapterTreeSchema, "rationChapterTrees")
|
|
var rationChapterTreeModel = chapterTreeDb.model("rationChapterTrees",rationChapterTreeSchema, "rationChapterTrees")
|
|
-var repositoryMap = require('./repository_map');
|
|
|
|
var counter = require('../../../public/counter/counter');
|
|
var counter = require('../../../public/counter/counter');
|
|
|
|
|
|
var rationChapterTreeDAO = function(){};
|
|
var rationChapterTreeDAO = function(){};
|
|
|
|
|
|
-rationChapterTreeDAO.prototype.getRationChapterTree = function(repositoryName,callback){
|
|
|
|
- repositoryMap.getRealLibName(repositoryName, function(err, rst){
|
|
|
|
- if (err || rst.length == 0) {
|
|
|
|
- callback("获取定额库错误!",false)
|
|
|
|
- } else {
|
|
|
|
- rationChapterTreeModel.find({"rationRepId": rst[0].ID, "$or": [{"isDeleted": null}, {"isDeleted": false} ]},function(err,data){
|
|
|
|
- if(data.length) callback(false,data);
|
|
|
|
- else if(err) callback("获取定额树错误!",false)
|
|
|
|
- else callback(false,false);
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+rationChapterTreeDAO.prototype.getRationChapterTree = function(rationLibId,callback){
|
|
|
|
+ rationChapterTreeModel.find({"rationRepId": rationLibId, "$or": [{"isDeleted": null}, {"isDeleted": false} ]},function(err,data){
|
|
|
|
+ if(data.length) callback(false,data);
|
|
|
|
+ else if(err) callback("获取定额树错误!",false)
|
|
|
|
+ else callback(false,false);
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
@@ -44,35 +37,27 @@ rationChapterTreeDAO.prototype.getRationChapterTreeByRepId = function(repId,call
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-rationChapterTreeDAO.prototype.createNewNode = function(repositoryName, lastNodeId, nodeData,callback){
|
|
|
|
- var promise = repositoryMap.getRealLibName(repositoryName), libId;
|
|
|
|
- if (promise) {
|
|
|
|
- promise.then(function(rst){
|
|
|
|
- libId = rst[0].ID;
|
|
|
|
- return counter.counterDAO.getIDAfterCount(counter.moduleName.rationTree, 1, function(err, result){
|
|
|
|
- nodeData.rationRepId = libId;
|
|
|
|
- nodeData.ID = result.value.sequence_value;
|
|
|
|
- var node = new rationChapterTreeModel(nodeData);
|
|
|
|
- node.save(function (err, result) {
|
|
|
|
- if (err) {
|
|
|
|
- callback("章节树ID错误!", false);
|
|
|
|
- } else {
|
|
|
|
- if (lastNodeId > 0) {
|
|
|
|
- rationChapterTreeModel.update({ID: lastNodeId}, {"NextSiblingID": nodeData.ID}, function(err, rst){
|
|
|
|
- if (err) {
|
|
|
|
- callback("章节树ID错误!", false);
|
|
|
|
- } else {
|
|
|
|
- callback(false, result);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- } else callback(false, result);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+rationChapterTreeDAO.prototype.createNewNode = function(libId, lastNodeId, nodeData,callback){
|
|
|
|
+ counter.counterDAO.getIDAfterCount(counter.moduleName.rationTree, 1, function(err, result){
|
|
|
|
+ nodeData.rationRepId = libId;
|
|
|
|
+ nodeData.ID = result.value.sequence_value;
|
|
|
|
+ var node = new rationChapterTreeModel(nodeData);
|
|
|
|
+ node.save(function (err, result) {
|
|
|
|
+ if (err) {
|
|
|
|
+ callback("章节树ID错误!", false);
|
|
|
|
+ } else {
|
|
|
|
+ if (lastNodeId > 0) {
|
|
|
|
+ rationChapterTreeModel.update({ID: lastNodeId}, {"NextSiblingID": nodeData.ID}, function(err, rst){
|
|
|
|
+ if (err) {
|
|
|
|
+ callback("章节树ID错误!", false);
|
|
|
|
+ } else {
|
|
|
|
+ callback(false, result);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else callback(false, result);
|
|
|
|
+ }
|
|
});
|
|
});
|
|
- } else {
|
|
|
|
- callback("定额库选择错误!", false);
|
|
|
|
- }
|
|
|
|
|
|
+ });
|
|
},
|
|
},
|
|
|
|
|
|
rationChapterTreeDAO.prototype.removeNodes = function(nodeIds, preNodeId, preNodeNextId, callback){
|
|
rationChapterTreeDAO.prototype.removeNodes = function(nodeIds, preNodeId, preNodeNextId, callback){
|