optlog.js 1020 B

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: 200 }, // 操作人id
  7. name: { type: String, required: false, maxLength: 200 }, // 操作人名称
  8. type: { type: String, required: false, maxLength: 200 }, // 操作人类别
  9. optmethod: { type: String, required: false }, // 操作方法
  10. optservice: { type: String, required: false }, // 操作接口
  11. optdata: { type: String, required: false }, // 操作数据
  12. opttime: { type: String, required: false }, // 操作时间
  13. status: { type: String, required: false }, // 操作状态
  14. };
  15. const schema = new Schema(OptlogSchema, { toJSON: { virtuals: true } });
  16. schema.index({ id: 1 });
  17. schema.index({ opttime: 1 });
  18. schema.index({ type: 1 });
  19. schema.plugin(metaPlugin);
  20. module.exports = app => {
  21. const { mongoose } = app;
  22. return mongoose.model('Optlog', schema, 'optlog');
  23. };