product.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. // 产品图片表
  6. const images = new Schema({
  7. url: { type: String, required: true }, // 图片路径
  8. });
  9. // 专利信息
  10. const patents = new Schema({
  11. patentinfo: { type: String, required: false }, // 专利信息,
  12. patentstatus: { type: String, required: false }, // 专利状态,
  13. });
  14. // 产品表
  15. const product = {
  16. name: { type: String, required: false }, // 名称
  17. contacts: { type: String, required: false }, // 联系人
  18. phone: { type: String, required: false }, // 联系电话
  19. qqwx: { type: String, required: false }, // qq&微信
  20. email: { type: String, required: false }, // 邮箱
  21. type: { type: String, required: false }, // 类型: 0-科技需求;1-技术成果;2-商务服务
  22. status: { type: String, required: false, default: '0' }, // 状态(0:草稿 1:审核中 2:审核通过 3:审核拒绝)
  23. user_id: { type: String, required: false }, // 创建人id
  24. // 共同字段
  25. field: { type: String, required: false }, // 所属领域
  26. cooperation: { type: String, required: false }, // 合作方式
  27. company: { type: String, required: false }, // 企业名称
  28. condition: { type: String, required: false }, // 合作条件及要求
  29. image: { type: [ images ] }, // 图片,产品图片都为此字段
  30. expect: { type: String, required: false }, // 预期, 所有的预期都合并为此字段
  31. demand: { type: String, required: false }, // 需求程度:技术的需求紧急程度和服务的需求程度改为此字段
  32. // 技术需求字段
  33. budget: { type: String, required: false }, // 投资预算
  34. requirementdesc: { type: String, required: false }, // 需求说明
  35. present: { type: String, required: false }, // 需求现状
  36. // 技术成果字段
  37. achievestatus: { type: String, required: false }, // 成果状态
  38. achieveown: { type: String, required: false }, // 成果权属
  39. achievesource: { type: String, required: false }, // 成果来源
  40. intentionprice: { type: String, required: false }, // 意向价格
  41. patent: { type: [ patents ] },
  42. roadshow: { type: String, required: false }, // 项目路演
  43. achievebrief: { type: String, required: false }, // 成果简介
  44. features: { type: String, required: false }, // 技术特点
  45. team: { type: String, required: false }, // 技术团队
  46. // 商务需求
  47. messattribute: { type: String, required: false }, // 信息属性
  48. informationdesc: { type: String, required: false }, // 信息描述
  49. coreelements: { type: String, required: false }, // 核心要素
  50. priceinfo: { type: String, required: false }, // 价格信息
  51. remark: { type: String },
  52. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  53. };
  54. const schema = new Schema(product, { toJSON: { virtuals: true } });
  55. schema.index({ id: 1 });
  56. schema.index({ name: 1 });
  57. schema.index({ qqwx: 1 });
  58. schema.index({ type: 1 });
  59. schema.index({ status: 1 });
  60. schema.index({ company: 1 });
  61. schema.index({ 'meta.createdAt': 1 });
  62. schema.plugin(metaPlugin);
  63. module.exports = app => {
  64. const { mongoose } = app;
  65. return mongoose.model('Product', schema, 'product');
  66. };