rpt_cfg.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * Created by Tony on 2017/6/14.
  3. */
  4. let mongoose = require('mongoose');
  5. let dbm = require("../../../config/db/db_manager");
  6. let smartcostdb = dbm.getCfgConnection("Reports");
  7. let Schema = mongoose.Schema;
  8. let FormatSchema = new Schema({
  9. "ID" : String,
  10. "CfgDispName": String,
  11. "Shrink" : String,
  12. "ShowZero" : String,
  13. "Horizon" : String,
  14. "Vertical" : String,
  15. "Wrap" : String
  16. });
  17. let FontSchema = new Schema({
  18. "ID" : String,
  19. "Name" : String,
  20. "CfgDispName": String,
  21. "FontHeight" : String,
  22. "FontColor" : String,
  23. "FontBold" : String,
  24. "FontItalic" : String,
  25. "FontUnderline" : String,
  26. "FontStrikeOut" : String,
  27. "FontAngle" : String
  28. });
  29. let LineSchema = new Schema({
  30. "Position": String,
  31. "LineWeight": String,
  32. "DashStyle": String,
  33. "Color": String
  34. });
  35. let StyleSchema = new Schema({
  36. "ID" : String,
  37. "CfgDispName": String,
  38. "border_style" : [LineSchema]
  39. });
  40. let RptCfgSchema = new Schema({
  41. "userId" : String,
  42. "fonts": [FontSchema],
  43. "borders" : [StyleSchema],
  44. "formats" : [FormatSchema]
  45. });
  46. let Rpt_Cfg_Mdl = smartcostdb.model("rpt_cfg", RptCfgSchema, "rpt_cfg");
  47. class RptCfgDAO {
  48. getByUserId(userId, callback){
  49. Rpt_Cfg_Mdl.find({userId: userId}, '-_id', function(err, templates){
  50. if(templates.length){
  51. callback(false, templates[0]);
  52. }
  53. else{
  54. callback('no record was found!');
  55. }
  56. })
  57. };
  58. getAll(id, callback){
  59. Rpt_Cfg_Mdl.find({}, '-_id', function(err, templates){
  60. if(templates.length){
  61. callback(false, templates);
  62. }
  63. else{
  64. callback('no record was found!');
  65. }
  66. })
  67. };
  68. };
  69. module.exports = new RptCfgDAO();