unitPriceFile.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * Created by jimiz on 2017/5/12.
  3. */
  4. var mongoose = require("mongoose");
  5. var db = require("../db/unitPriceFile_db");
  6. var Schema = mongoose.Schema;
  7. var deleteSchema = require('../../../public/models/delete_schema');
  8. var consts = require('../../main/models/projectConsts');
  9. var projectConsts = consts.projectConst;
  10. var commonConsts = consts.commonConst;
  11. var GLJList = require('./GLJList');
  12. var unitPriceFileSchema = new Schema({
  13. ID: Number,
  14. name: String,
  15. version: Number,
  16. projects: Array,
  17. deleteInfo: deleteSchema
  18. });
  19. var unitPriceFile = db.model("unitPriceFile", unitPriceFileSchema, "unitPriceFile");
  20. var unitPriceFileDAO = function(){};
  21. unitPriceFileDAO.prototype.getData = function(fileID, callback){
  22. unitPriceFile.find({'$or': [{fileID: fileID, deleteInfo: null}, {fileID: fileID, 'deleteInfo.deleted': {$in: [null, false]}}]}, '-_id', function(err, datas){
  23. if (!err) {
  24. callback(0, projectConsts.UNITPRICEFILE, datas);
  25. } else {
  26. callback(1, '', null);
  27. }
  28. });
  29. };
  30. unitPriceFileDAO.prototype.save = function(fileId, datas, callback){
  31. function changed(err, changedDatas){
  32. sync(fileId, changedDatas, callback);
  33. }
  34. GLJList.save(fileID, datas, changed);
  35. };
  36. unitPriceFileDAO.prototype.sync = function(fileId, datas, callback){
  37. };
  38. unitPriceFileDAO.prototype.newFile = function(data, callback){
  39. };
  40. unitPriceFileDAO.prototype.add = function(count, callback){
  41. GLJList.add(count, callback);
  42. };
  43. module.exports = new unitPriceFileDAO();