'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const { Secret } = require('naf-framework-mongoose/lib/model/schema'); // 企业用户表 const CompanyuserSchema = { phone: { type: String, required: true, maxLength: 100 }, // 手机 passwd: { type: { Secret }, select: false }, // 注册密码 company_name: { type: String, required: false, maxLength: 200 }, // 企业名称 person: { type: String, required: true, maxLength: 200 }, // 联系人姓名 institution_name: { type: String, required: false, maxLength: 200 }, // 推荐单位名称 roles: { type: String, required: false, maxLength: 200, default: '0' }, // 企业用户权限,0-注册(只可浏览),1-认证(可申请),2-上传财务信息(皆可) }; const schema = new Schema(CompanyuserSchema, { toJSON: { virtuals: true } }); schema.index({ phone: 1 }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Companyuser', schema, 'company_user'); };