|
@@ -0,0 +1,34 @@
|
|
|
+'use strict';
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
|
|
|
+
|
|
|
+// 商店信息
|
|
|
+const shop = {
|
|
|
+ logo: { type: Array, required: false, zh: '店铺logo' }, //
|
|
|
+ name: { type: String, required: false, zh: '商店名称' }, //
|
|
|
+ code: { type: String, required: false, zh: '店铺编号' }, // 自增,中间件处理
|
|
|
+ person: { type: String, required: false, zh: '店主' }, //
|
|
|
+ phone: { type: String, required: false, zh: '联系电话' }, //
|
|
|
+ address: { type: String, required: false, zh: '地址' }, //
|
|
|
+ file: { type: Array, required: false, zh: '证件照片' }, //
|
|
|
+ status: { type: String, required: false, zh: '店铺状态' }, // 字典:shop_status
|
|
|
+ goods_score: { type: Number, required: false, default: 5, zh: '商品评分' }, //
|
|
|
+ send_score: { type: Number, required: false, default: 5, zh: '发货评分' }, //
|
|
|
+ service_score: { type: Number, required: false, default: 5, zh: '服务评分' }, //
|
|
|
+ qrcode: { type: Array, required: false, zh: '二维码' }, //
|
|
|
+};
|
|
|
+const schema = new Schema(shop, { toJSON: { getters: true, virtuals: true } });
|
|
|
+schema.index({ id: 1 });
|
|
|
+schema.index({ 'meta.createdAt': 1 });
|
|
|
+schema.index({ name: 1 });
|
|
|
+schema.index({ code: 1 });
|
|
|
+schema.index({ person: 1 });
|
|
|
+schema.index({ phone: 1 });
|
|
|
+schema.index({ status: 1 });
|
|
|
+
|
|
|
+schema.plugin(metaPlugin);
|
|
|
+module.exports = app => {
|
|
|
+ const { mongoose } = app;
|
|
|
+ return mongoose.model('Shop', schema, 'shop');
|
|
|
+};
|
|
|
+
|