expert.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  5. const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
  6. const { ObjectId } = require('mongoose').Types;
  7. // 专家表
  8. const expert = {
  9. name: { type: String, required: true }, // 用户名
  10. phone: { type: String, required: false, maxLength: 200 }, // 电话号码
  11. password: { type: Secret, required: true, select: false }, // 登录密码
  12. card: { type: String, required: false, maxLength: 200 }, // 身份证号
  13. birth: { type: String, required: false, maxLength: 500 }, // 出生日期
  14. qqwx: { type: String, required: false, maxLength: 500 }, // qq&微信
  15. email: { type: String, required: false, maxLength: 500 }, // 邮箱
  16. zwzc: { type: String, required: false, maxLength: 500 }, // 职务职称
  17. education: { type: String, required: false, maxLength: 500 }, // 最高学历
  18. school: { type: String, required: false, maxLength: 500 }, // 毕业院校
  19. major: { type: String, required: false, maxLength: 200 }, // 专业
  20. company: { type: String, required: false, maxLength: 500 }, // 单位名称
  21. icon: { type: Array, required: false }, // 头像图片
  22. expertise: { type: String, required: false, maxLength: 500 }, // 擅长领域
  23. workexperience: { type: String, required: false, maxLength: 500 }, // 工作经历
  24. scientific: { type: String, required: false, maxLength: 500 }, // 科研综述
  25. undertakingproject: { type: String, required: false, maxLength: 500 }, // 承担项目
  26. scienceaward: { type: String, required: false, maxLength: 500 }, // 科技奖励
  27. social: { type: String, required: false, maxLength: 500 }, // 社会任职
  28. status: { type: String, required: false, default: '0', maxLength: 500 }, // 审核状态,0-注册,1-通过,2-拒绝
  29. remark: { type: String, maxLength: 200 },
  30. };
  31. const schema = new Schema(expert, { toJSON: { virtuals: true } });
  32. schema.index({ id: 1 });
  33. schema.index({ name: 1 });
  34. schema.index({ phone: 1 });
  35. schema.index({ card: 1 });
  36. schema.index({ education: 1 });
  37. schema.index({ status: 1 });
  38. schema.index({ 'meta.createdAt': 1 });
  39. schema.plugin(metaPlugin);
  40. module.exports = app => {
  41. const { mongoose } = app;
  42. return mongoose.model('Expert', schema, 'expert');
  43. };