rpt_template.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * Created by Tony on 2016/12/23.
  3. */
  4. var mongoose = require('mongoose');
  5. var dbm = require("../../../config/db/db_manager");
  6. var smartcostdb = dbm.getCfgConnection("Reports");
  7. var Schema = mongoose.Schema;
  8. var RptTemplateSchema = new Schema({
  9. "GROUP_KEY": String,
  10. "ID_KEY": String,
  11. "主信息": Schema.Types.Mixed,
  12. "指标_数据_映射": Schema.Types.Mixed,
  13. "布局框_集合": Array,
  14. "流水式表_信息": Schema.Types.Mixed,
  15. "交叉表_信息": Schema.Types.Mixed,
  16. "无映射离散指标_集合": Schema.Types.Mixed,
  17. "离散参数_集合": Schema.Types.Mixed,
  18. "计算式_集合": Array
  19. });
  20. var Template = smartcostdb.model("rpt_templates", RptTemplateSchema, "rpt_templates");
  21. var RplTplDAO = function(){};
  22. RplTplDAO.prototype.get = function(grpId, id, callback){
  23. Template.find({GROUP_KEY: grpId, ID_KEY: id}, '-_id', function(err, templates){
  24. if(templates.length){
  25. callback(false, templates[0]);
  26. }
  27. else{
  28. callback('查找不到报表模板!');
  29. }
  30. })
  31. };
  32. RplTplDAO.prototype.getPromise = function(grpId, id){
  33. var rst = Template.findOne({GROUP_KEY: grpId, ID_KEY: id}, '-_id').exec() ;
  34. return rst;
  35. }
  36. module.exports = new RplTplDAO();