'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; const { Secret } = require('naf-framework-mongoose/lib/model/schema'); // 专家临时账号表 // 使用手机号密码登录 // 约束条件,不能出现一个专家同时审2个项目,否则登录可能混乱 const achieve_expert = { expert_user_id: { type: ObjectId }, // 专家的用户id expert_name: { type: String }, // 专家姓名 phone: { type: String }, // 电话 apply_id: { type: ObjectId }, // 成果申请id password: { type: Secret, select: false }, verify: { type: Object }, // 评审详情:分数:score;意见:content status: { type: String, default: '0' }, // 0=>使用中;-1=>禁用中 remark: { type: String, maxLength: 200 }, create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') }, }; const schema = new Schema(achieve_expert, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ expert_user_id: 1 }); schema.index({ expert_name: 1 }); schema.index({ phone: 1 }); schema.index({ apply_id: 1 }); schema.index({ status: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Achieve_expert', schema, 'achieve_expert'); };