examine.js 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. const { ObjectId } = require('mongoose').Types;
  5. // 审批表
  6. const examine = {
  7. order_num: { type: String }, // 审批单号
  8. personal: { type: String }, // 审批人
  9. examine_time: { type: String }, // 审批时间
  10. opinion: { type: String }, // 审批意见
  11. status: { type: String }, // 审批结果 【0:待审中,1:审核通过,2:审核未通过】
  12. totalMoney: { type: Number }, // 购买总价
  13. order: { type: Array }, // 订单数组
  14. buy_id: { type: ObjectId }, // 购买人id
  15. buy_name: { type: String }, // 购买人姓名
  16. remark: { type: String }, //
  17. };
  18. const schema = new Schema(examine, { toJSON: { virtuals: true } });
  19. schema.index({ id: 1 });
  20. schema.index({ order_num: 1 });
  21. schema.index({ personal: 1 });
  22. schema.index({ examine_time: 1 });
  23. schema.index({ status: 1 });
  24. schema.index({ totalMoney: 1 });
  25. schema.index({ buy_id: 1 });
  26. schema.index({ buy_name: 1 });
  27. schema.index({ 'meta.createdAt': 1 });
  28. schema.plugin(metaPlugin);
  29. module.exports = app => {
  30. const { mongoose } = app;
  31. return mongoose.model('Examine', schema, 'examine');
  32. };