organization.js 2.7 KB

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