12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- /**
- * Created by Tony on 2017/4/21.
- */
- 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,
- ID:Number,
- ParentID:Number,
- NextSiblingID:Number,
- dispName: String
- });
- var rationChapterTreeModel = chapterTreeDb.model("rationChapterTrees",rationChapterTreeSchema, "rationChapterTrees")
- var repositoryMap = require('./repositoryMap');
- var counter = require('../../../public/counter/counter');
- var rationChapterTreeDAO = function(){};
- 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.createNewNode = function(repositoryName,nodeData,callback){
- repositoryMap.getRealLibName(repositoryName, function(err, rst){
- //
- })
- },
- 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)
- else callback(false,"ok")
- })
- }
- 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){
- rationChapterTreeModel.update({'sectionId':section.sectionId},section,function(err,data){
- if(err){
- callback(" ",false);
- }else
- callback(false,"ok");
- });
- }else{
- var N = new rationChapterTreeModel(section).save(function(err){
- if(err){
- callback(" ",false);
- }else
- callback(false,"success!");
- })
- }
- })
- }
- //待 ration模块完成
- 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){
- })
- }
- module.exports = new rationChapterTreeDAO()
|