123456789101112131415161718192021222324252627282930313233 |
- '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 admin = {
- name: { type: String }, // 名称
- phone: { type: String }, // 手机
- password: { type: Secret, select: false }, // 注册密码
- openid: { type: String }, // 微信openid
- role: { type: String }, // 角色: 0:超级管理员;1:管理员;2:机构管理员;3:业务管理员
- pid: { type: String }, // 上级id
- deptname: { type: String }, // 机构名称
- code: { type: String }, // 邀请码
- remark: { type: String, maxLength: 200 },
- role_id: { type: String }, // 关联角色id
- };
- const schema = new Schema(admin, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ name: 1 });
- schema.index({ phone: 1 });
- schema.index({ role: 1 });
- schema.index({ pid: 1 });
- schema.index({ code: 1 });
- schema.index({ role_id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Admin', schema, 'admin');
- };
|