notice.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. // 消息
  6. const notice = {
  7. message: {
  8. type: String,
  9. required: true,
  10. maxLength: 200,
  11. field: { label: '提示信息', required: true },
  12. },
  13. effect_id: {
  14. type: String,
  15. required: true,
  16. maxLength: 200,
  17. field: { label: '产生警告的id', required: true },
  18. },
  19. column: {
  20. type: String,
  21. required: true,
  22. maxLength: 200,
  23. field: { label: '产生警告的字段', required: true },
  24. },
  25. check_date: {
  26. type: String,
  27. required: true,
  28. maxLength: 200,
  29. field: { label: '产生警告时,受检查的日期(最后日期)', required: true },
  30. },
  31. user_id: {
  32. type: String,
  33. required: true,
  34. maxLength: 200,
  35. field: { label: '被提示人员', required: true },
  36. },
  37. status: {
  38. type: String,
  39. maxLength: 200,
  40. default: '0',
  41. field: {
  42. label: '状态',
  43. filter: 'select',
  44. type: 'select',
  45. format: (i => (i === '0' ? '提示' : '禁止')).toString(),
  46. list: [
  47. { label: '提示', value: '0' },
  48. { label: '禁止', value: '1' },
  49. ],
  50. },
  51. }, // 状态:0=>使用;1禁用
  52. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  53. };
  54. const schema = new Schema(notice, { toJSON: { virtuals: true } });
  55. schema.index({ id: 1 });
  56. schema.plugin(metaPlugin);
  57. module.exports = app => {
  58. const { mongoose } = app;
  59. return mongoose.model('Notice', schema, 'notice');
  60. };