status.js 982 B

123456789101112131415161718192021222324252627
  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. const { ObjectId } = require('mongoose').Types;
  6. // 客服状态表
  7. const status = {
  8. customer_id: { type: ObjectId }, // 客服id
  9. customer_name: { type: String }, // 客服名
  10. status: { type: String, default: '0' }, // 状态:0-空闲;1-接待中
  11. _tenant: { type: String, default: 'master' }, // 哪个项目
  12. logout_time: { type: String }, // 失效时间
  13. remark: { type: String },
  14. };
  15. const schema = new Schema(status, { toJSON: { virtuals: true } });
  16. schema.index({ id: 1 });
  17. schema.index({ customer_id: 1 });
  18. schema.index({ customer_name: 1 });
  19. schema.index({ status: 1 });
  20. schema.index({ _tenant: 1 });
  21. schema.index({ 'meta.createdAt': 1 });
  22. schema.plugin(metaPlugin);
  23. module.exports = app => {
  24. const { mongoose } = app;
  25. return mongoose.model('Status', schema, 'status');
  26. };
  27. // 定期进行清除