achieve_expert.js 1.4 KB

123456789101112131415161718192021222324252627282930313233
  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. const { Secret } = require('naf-framework-mongoose/lib/model/schema');
  7. // 专家临时账号表
  8. // 使用手机号密码登录
  9. // 约束条件,不能出现一个专家同时审2个项目,否则登录可能混乱
  10. const achieve_expert = {
  11. expert_user_id: { type: ObjectId }, // 专家的用户id
  12. expert_name: { type: String }, // 专家姓名
  13. phone: { type: String }, // 电话
  14. apply_id: { type: ObjectId }, // 成果申请id
  15. password: { type: Secret, select: false },
  16. verify: { type: Object }, // 评审详情:分数:score;意见:content
  17. status: { type: String, default: '0' }, // 0=>使用中;-1=>禁用中
  18. remark: { type: String, maxLength: 200 },
  19. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  20. };
  21. const schema = new Schema(achieve_expert, { toJSON: { virtuals: true } });
  22. schema.index({ id: 1 });
  23. schema.index({ expert_user_id: 1 });
  24. schema.index({ expert_name: 1 });
  25. schema.index({ phone: 1 });
  26. schema.index({ apply_id: 1 });
  27. schema.index({ status: 1 });
  28. schema.index({ 'meta.createdAt': 1 });
  29. schema.plugin(metaPlugin);
  30. module.exports = app => {
  31. const { mongoose } = app;
  32. return mongoose.model('Achieve_expert', schema, 'achieve_expert');
  33. };