optlog.js 1.2 KB

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 文件导入表
  5. const OptlogSchema = {
  6. userid: { type: String, required: false, maxLength: 64 }, // 操作人
  7. name: { type: String, required: false, maxLength: 200 }, // 名称
  8. unitid: { type: String, required: false, maxLength: 64 }, // 学校/分站id
  9. ip: { type: String, required: false, maxLength: 64 }, // ip地址
  10. createtime: { type: String, required: false, maxLength: 20 }, // 时间
  11. type: { type: String, required: false, maxLength: 64 }, // 操作类型: 1. 添加 2.修改 3. 删除 4.查询
  12. target: { type: String, required: false, maxLength: 200 }, // 操作目标,根据页面的menu页区分
  13. content: { type: String, required: false, maxLength: 64 }, // 描述
  14. status: { type: String, required: false, maxLength: 2 }, // 操作结果
  15. remark: { type: String, required: false, maxLength: 200 }, // 备注
  16. };
  17. const schema = new Schema(OptlogSchema, { toJSON: { virtuals: true } });
  18. schema.index({ userid: 1 });
  19. schema.plugin(metaPlugin);
  20. module.exports = app => {
  21. const { mongoose } = app;
  22. return mongoose.model('Optlog', schema, 'opt_log');
  23. };