|
@@ -0,0 +1,29 @@
|
|
|
|
+'use strict';
|
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
|
+const moment = require('moment');
|
|
|
|
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
|
|
|
|
+const { ObjectId } = require('mongoose').Types;
|
|
|
|
+// 咨询服务表
|
|
|
|
+const service = {
|
|
|
|
+ user_id: { type: ObjectId },
|
|
|
|
+ title: { type: String }, // 标题
|
|
|
|
+ origin: { type: String }, // 来源
|
|
|
|
+ renew_time: { type: String }, // 更新时间
|
|
|
|
+ type: { type: String }, // 类型:0=>文字;1=>图文;2=>科普视频;3=>培训视频
|
|
|
|
+ content: { type: String }, // 内容
|
|
|
|
+ imgUrl: { type: Array }, // 图片 [{url:uri}]
|
|
|
|
+ fileUrl: { type: Array }, // 视频 [{url:uri}]
|
|
|
|
+ contact: { type: Object }, // 服务联系人:name-姓名;phone-联系电话;email-电子邮箱;address-联系地址
|
|
|
|
+ read: { type: Number, default: 0 }, // 阅读数
|
|
|
|
+ remark: { type: String, maxLength: 200 },
|
|
|
|
+ create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') },
|
|
|
|
+};
|
|
|
|
+const schema = new Schema(service, { toJSON: { virtuals: true } });
|
|
|
|
+schema.index({ id: 1 });
|
|
|
|
+schema.index({ user_id: 1 });
|
|
|
|
+schema.index({ 'meta.createdAt': 1 });
|
|
|
|
+schema.plugin(metaPlugin);
|
|
|
|
+module.exports = app => {
|
|
|
|
+ const { mongoose } = app;
|
|
|
|
+ return mongoose.model('Service', schema, 'service');
|
|
|
|
+};
|