personal.js 2.1 KB

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