companyuser.js 1.1 KB

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