'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 UserSchema = { name: { type: String, required: true, maxLength: 200 }, // 用户名 password: { type: Secret, required: true, select: false }, // 登录密码 cardnumber: { type: String, required: false, maxLength: 500 }, // 身份证号 phone: { type: String, required: false, maxLength: 200 }, // 电话号码 email: { type: String, required: false, maxLength: 200 }, // 邮箱 addr: { type: String, required: false, maxLength: 500 }, // 地址 img_path: { type: String, required: false }, // 头像图片 is_qy: { type: String, required: false, maxLength: 500 }, // 个人或法人,0-个人1-法人 cardfile_a: { type: String, required: false }, // 身份证正面 cardfile_b: { type: String, required: false }, // 身份证背面 img_qy: { type: String, required: false }, // 组织机构图片 resume: { type: String, required: false }, // 个人简介 major: { type: String, required: false }, // 专业领域 institution_type: { type: String, required: false, maxLength: 500 }, // 机构类型 institution_name: { type: String, required: false, maxLength: 500 }, // 机构名称 institution_code: { type: String, required: false, maxLength: 500 }, // 机构代码 institution_nature: { type: String, required: false, maxLength: 500 }, // 机构性质 office_phone: { type: String, required: false, maxLength: 500 }, // 办公电话 profession: { type: String, required: false, maxLength: 500 }, // 所属行业 status: { type: String, required: false, default: '0', maxLength: 200 }, // 审核状态,0-注册,1-通过,2-拒绝 is_del: { type: String, required: false, maxLength: 200 }, // 是否删除,0-否,1-是 role: { type: String, required: false, maxLength: 200 }, // 1-管理员,2-个人,3-企业管理员,4-子管理员 token: { type: String, required: false, maxLength: 500 }, // 令牌 columnid: [ String ], pid: { type: String, required: false }, // 父id deptname: { type: String, required: false }, // 机构名称 code: { type: String, required: false }, // 邀请码 openid: { type: String, required: false }, // 微信openid }; const schema = new Schema(UserSchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('User', schema, 'market_user'); };