organization.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. const { Secret } = require('naf-framework-mongoose/lib/model/schema');
  6. // 机构表
  7. const organization = {
  8. name: { type: String, required: true, maxLength: 200 }, // 用户名
  9. password: { type: Secret, required: true, select: false }, // 登录密码
  10. phone: { type: String, required: false, maxLength: 200 }, // 电话号码
  11. email: { type: String, required: false, maxLength: 200 }, // 邮箱
  12. addr: { type: String, required: false, maxLength: 500 }, // 地址
  13. office_phone: { type: String, required: false, maxLength: 500 }, // 办公电话
  14. profession: { type: String, required: false, maxLength: 500 }, // 所属行业
  15. institution_code: { type: String, required: false, maxLength: 500 }, // 机构代码
  16. code: { type: String, required: false, default: 'INVESTORS' }, // 邀请码
  17. companytype: { type: String, required: false, maxLength: 300 }, // 注册类型
  18. companydate: { type: String, required: false, maxLength: 300 }, // 注册时间
  19. companycapital: { type: String, required: false, maxLength: 300 }, // 注册资金
  20. companyperson: { type: String, required: false, maxLength: 300 }, // 企业法人
  21. sndqyzsr: { type: String, required: false, maxLength: 300 }, // 上年度企业总收入
  22. sndyffy: { type: String, required: false, maxLength: 300 }, // 上年度研发费用
  23. companytotal: { type: String, required: false, maxLength: 300 }, // 企业总人数
  24. zjzyfrs: { type: String, required: false, maxLength: 300 }, // 专&兼职研发人数
  25. companybrief: { type: String, required: false }, // 企业简介
  26. mainproduct: { type: String, required: false, maxLength: 300 }, // 主要产品
  27. qualifications: { type: String, required: false, maxLength: 300 }, // 企业资质&荣誉
  28. status: { type: String, required: false, default: '0', maxLength: 200 }, // 审核状态,0-注册,1-通过,2-拒绝
  29. juris: { type: String }, // 辖区
  30. openid: { type: String }, // 微信openid
  31. isdel: { type: String, required: false, default: '0' }, // 0=>未删除;1=>已删除
  32. remark: { type: String, maxLength: 200 },
  33. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  34. };
  35. const schema = new Schema(organization, { toJSON: { virtuals: true } });
  36. schema.index({ id: 1 });
  37. schema.index({ phone: 1 });
  38. schema.index({ profession: 1 });
  39. schema.index({ institution_code: 1 });
  40. schema.index({ companyperson: 1 });
  41. schema.index({ 'meta.createdAt': 1 });
  42. schema.plugin(metaPlugin);
  43. module.exports = app => {
  44. const { mongoose } = app;
  45. return mongoose.model('Organization', schema, 'organization');
  46. };