company.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 公司信息
  5. const company = {
  6. name: { type: String, required: false, zh: '公司名称' }, //
  7. logo_url: { type: Array, required: false, zh: '公司logo' }, //
  8. address: { type: String, required: false, zh: '公司地址' }, //
  9. contact: { type: String, required: false, zh: '联系人' }, //
  10. phone: { type: String, required: false, zh: '联系电话' }, //
  11. qq: { type: String, required: false, zh: 'qq' }, //
  12. email: { type: String, required: false, zh: '电子邮箱' }, //
  13. mobile: { type: String, required: false, zh: '座机' }, //
  14. advantage: { type: Array, required: false, zh: '公司优势' }, //
  15. programme: { type: Array, required: false, zh: '解决方案' }, //
  16. idea: { type: String, required: false, zh: '品牌理念' }, //
  17. unique: { type: String, required: false, zh: '独特优势' }, //
  18. join: { type: String, required: false, zh: '加入我们' }, //
  19. };
  20. const schema = new Schema(company, { toJSON: { getters: true, virtuals: true } });
  21. schema.index({ id: 1 });
  22. schema.index({ 'meta.createdAt': 1 });
  23. schema.index({ name: 1 });
  24. schema.index({ address: 1 });
  25. schema.index({ contact: 1 });
  26. schema.index({ phone: 1 });
  27. schema.index({ qq: 1 });
  28. schema.index({ email: 1 });
  29. schema.index({ mobile: 1 });
  30. schema.plugin(metaPlugin);
  31. module.exports = app => {
  32. const { mongoose } = app;
  33. return mongoose.model('Company', schema, 'company');
  34. };