expert.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 { Secret } = require('naf-framework-mongoose/lib/model/schema');
  6. const { ObjectId } = require('mongoose').Types;
  7. // 专家表
  8. const expert = {
  9. user_id: { type: ObjectId }, // 关联的personal的id
  10. // user
  11. name: { type: String, required: true }, // 用户名
  12. phone: { type: String, required: false }, // 电话号码
  13. passwd: { type: Secret, required: true, select: false }, // 登录密码
  14. addr: { type: String, required: false }, // 地址
  15. office_phone: { type: String, required: false }, // 办公电话
  16. profession: { type: String, required: false }, // 所属行业
  17. education: { type: String, required: false }, // 最高学历
  18. school: { type: String, required: false }, // 毕业院校
  19. birthDate: { type: String, required: false }, // 出生日期
  20. qqwx: { type: String, required: false }, // qq&微信
  21. email: { type: String, required: false }, // 邮箱
  22. company: { type: String, required: false }, // 单位名称
  23. zwzc: { type: String, required: false }, // 职务职称
  24. expertise: { type: String, required: false }, // 擅长领域
  25. img_path: { type: Array, required: false }, // 头像图片
  26. workexperience: { type: String, required: false }, // 工作经历
  27. scientific: { type: String, required: false, maxLength: 300 }, // 科研综述
  28. undertakingproject: { type: String, required: false }, // 承担项目
  29. scienceaward: { type: String, required: false }, // 科技奖励
  30. social: { type: String, required: false }, // 社会任职
  31. status: { type: String, required: false, default: '0' }, // 审核状态,0-注册,1-通过,2-拒绝
  32. isdel: { type: String, required: false, default: '0' }, // 0=>未删除;1=>已删除
  33. remark: { type: String },
  34. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  35. };
  36. const schema = new Schema(expert, { toJSON: { virtuals: true } });
  37. schema.index({ id: 1 });
  38. schema.index({ phone: 1 });
  39. schema.index({ code: 1 });
  40. schema.index({ status: 1 });
  41. schema.index({ 'meta.createdAt': 1 });
  42. schema.plugin(metaPlugin);
  43. module.exports = app => {
  44. const { mongoose } = app;
  45. return mongoose.model('Expert', schema, 'expert');
  46. };