123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
- // 个人用户表
- const personal = {
- name: { type: String, required: true }, // 用户名
- phone: { type: String, required: false, maxLength: 200 }, // 电话号码
- password: { type: Secret, required: true, select: false }, // 登录密码
- code: { type: String, required: false, default: "INVESTORS" }, // 邀请码
- role: { type: String, required: false, default: "3" }, // 角色
- email: { type: String, required: false, maxLength: 200 }, // 邮箱
- addr: { type: String, required: false, maxLength: 500 }, // 地址
- office_phone: { type: String, required: false, maxLength: 500 }, // 办公电话
- profession: { type: String, required: false, maxLength: 500 }, // 所属行业
- juris: { type: String }, // 辖区
- card: { type: String, required: false, maxLength: 200 }, // 身份证号
- zwzc: { type: String, required: false, maxLength: 200 }, // 职务职称
- school: { type: String, required: false, maxLength: 500 }, // 院系
- major: { type: String, required: false, maxLength: 200 }, // 专业
- status: { type: String, required: false, default: "0", maxLength: 200 }, // 审核状态,0-注册,1-通过,2-拒绝
- openid: { type: String, required: false }, // 微信openid
- isdel: { type: String, required: false, maxLength: 200, default: "0" }, // 是否删除,0-否,1-是
- remark: { type: String, maxLength: 200 },
- is_expert: { type: Boolean, default: false }, // 是否是专家
- create_time: { type: String },
- };
- const schema = new Schema(personal, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ name: 1 });
- schema.index({ phone: 1 });
- schema.index({ code: 1 });
- schema.index({ status: 1 });
- schema.index({ juris: 1 });
- schema.index({ profession: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Personal', schema, 'personal');
- };
|