personal.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // 个人用户表
  7. const personal = {
  8. name: { type: String, required: true }, // 用户名
  9. password: { type: Secret, required: true, select: false }, // 登录密码
  10. phone: { type: String, required: false, maxLength: 200 }, // 电话号码
  11. email: { type: String, required: false, maxLength: 200 }, // 邮箱
  12. addr: { type: String, required: false, maxLength: 500 }, // 地址
  13. office_phone: { type: String, required: false, maxLength: 500 }, // 办公电话
  14. profession: { type: String, required: false, maxLength: 500 }, // 所属行业
  15. code: { type: String, required: false, default: 'INVESTORS' }, // 邀请码
  16. openid: { type: String, required: false }, // 微信openid
  17. status: { type: String, required: false, default: '0', maxLength: 200 }, // 审核状态,0-注册,1-通过,2-拒绝
  18. isdel: { type: String, required: false, maxLength: 200, default: '0' }, // 是否删除,0-否,1-是
  19. remark: { type: String, maxLength: 200 },
  20. juris: { type: String }, // 辖区
  21. is_expert: { type: Boolean, default: false }, // 是否是专家
  22. school: { type: String, required: false, maxLength: 500 }, // 院系
  23. major: { type: String, required: false, maxLength: 200 }, // 专业
  24. card: { type: String, required: false, maxLength: 200 }, // 身份证号
  25. zwzc: { type: String, required: false, maxLength: 200 }, // 职务职称
  26. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  27. };
  28. const schema = new Schema(personal, { toJSON: { virtuals: true } });
  29. schema.index({ id: 1 });
  30. schema.index({ name: 1 });
  31. schema.index({ phone: 1 });
  32. schema.index({ code: 1 });
  33. schema.index({ status: 1 });
  34. schema.index({ juris: 1 });
  35. schema.index({ profession: 1 });
  36. schema.index({ 'meta.createdAt': 1 });
  37. schema.plugin(metaPlugin);
  38. module.exports = app => {
  39. const { mongoose } = app;
  40. return mongoose.model('Personal', schema, 'personal');
  41. };