|
@@ -0,0 +1,35 @@
|
|
|
|
+'use strict';
|
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
|
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
|
|
|
|
+
|
|
|
|
+const reply = {
|
|
|
|
+ content: { type: String, zh: '内容' },
|
|
|
|
+ file: { type: Array, zh: '图片' },
|
|
|
|
+ // reply:reply,
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 商品评价
|
|
|
|
+const goodsRate = {
|
|
|
|
+ customer: { type: String, required: false, zh: '用户', ref: 'User.User' }, //
|
|
|
|
+ shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, //
|
|
|
|
+ goods: { type: String, required: false, zh: '商品', ref: 'Shop.Goods' }, //
|
|
|
|
+ goodsSpec: { type: String, required: false, zh: '规格', ref: 'Shop.GoodsSpec' }, //
|
|
|
|
+ reply: { type: Object, required: false, zh: '回复' }, //
|
|
|
|
+ goods_score: { type: Number, required: false, zh: '商品评分' }, //
|
|
|
|
+ shop_score: { type: Number, required: false, zh: '店铺评分' }, //
|
|
|
|
+ transport_score: { type: Number, required: false, zh: '快递评分' }, //
|
|
|
|
+};
|
|
|
|
+const schema = new Schema(goodsRate, { toJSON: { getters: true, virtuals: true } });
|
|
|
|
+schema.index({ id: 1 });
|
|
|
|
+schema.index({ 'meta.createdAt': 1 });
|
|
|
|
+schema.index({ customer: 1 });
|
|
|
|
+schema.index({ shop: 1 });
|
|
|
|
+schema.index({ goods: 1 });
|
|
|
|
+schema.index({ goodsSpec: 1 });
|
|
|
|
+
|
|
|
|
+schema.plugin(metaPlugin);
|
|
|
|
+
|
|
|
|
+module.exports = app => {
|
|
|
|
+ const { mongoose } = app;
|
|
|
|
+ return mongoose.model('GoodsRate', schema, 'goodsRate');
|
|
|
|
+};
|