'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 消息 const notice = { message: { type: String, required: true, maxLength: 200, field: { label: '提示信息', required: true }, }, effect_id: { type: String, required: true, maxLength: 200, field: { label: '产生警告的id', required: true }, }, column: { type: String, required: true, maxLength: 200, field: { label: '产生警告的字段', required: true }, }, check_date: { type: String, required: true, maxLength: 200, field: { label: '产生警告时,受检查的日期(最后日期)', required: true }, }, user_id: { type: String, required: true, maxLength: 200, field: { label: '被提示人员', required: true }, }, status: { type: String, maxLength: 200, default: '0', field: { label: '状态', filter: 'select', type: 'select', format: (i => (i === '0' ? '提示' : '禁止')).toString(), list: [ { label: '提示', value: '0' }, { label: '禁止', value: '1' }, ], }, }, // 状态:0=>使用;1禁用 create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') }, }; const schema = new Schema(notice, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Notice', schema, 'notice'); };