123456789101112131415161718192021222324252627282930313233343536373839404142 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const { Secret } = require('naf-framework-mongoose/lib/model/schema');
- // 个人用户表
- const personal = {
- name: { type: String, required: true }, // 用户名
- password: { type: Secret, required: true, select: false }, // 登录密码
- phone: { type: String, required: false, maxLength: 200 }, // 电话号码
- 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 }, // 所属行业
- code: { type: String, required: false, default: 'INVESTORS' }, // 邀请码
- openid: { type: String, required: false }, // 微信openid
- status: { type: String, required: false, default: '0', maxLength: 200 }, // 审核状态,0-注册,1-通过,2-拒绝
- isdel: { type: String, required: false, maxLength: 200, default: '0' }, // 是否删除,0-否,1-是
- remark: { type: String, maxLength: 200 },
- juris: { type: String }, // 辖区
- is_expert: { type: Boolean, default: false }, // 是否是专家
- school: { type: String, required: false, maxLength: 500 }, // 院系
- major: { type: String, required: false, maxLength: 200 }, // 专业
- card: { type: String, required: false, maxLength: 200 }, // 身份证号
- zwzc: { type: String, required: false, maxLength: 200 }, // 职务职称
- create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
- };
- 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');
- };
|