lrf 2 年之前
父节点
当前提交
0955b034a2
共有 4 个文件被更改,包括 62 次插入2 次删除
  1. 2 2
      app/controller/config/.zrGoods.js
  2. 26 0
      app/model/base/point.js
  3. 33 0
      app/model/base/user.js
  4. 1 0
      app/model/zrGoods.js

+ 2 - 2
app/controller/config/.zrGoods.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ['cost', 'shop', 'name', 'shot_brief', 'send_time', 'brief', 'file', 'view_num', 'sell_num', 'status', 'sort'],
+    requestBody: ['num', 'cost', 'shop', 'name', 'shot_brief', 'send_time', 'brief', 'file', 'view_num', 'sell_num', 'status', 'sort'],
   },
   destroy: {
     params: ['!id'],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ['!id'],
-    requestBody: ['cost', 'shop', 'name', 'shot_brief', 'send_time', 'brief', 'file', 'view_num', 'sell_num', 'status', 'sort'],
+    requestBody: ['num', 'cost', 'shop', 'name', 'shot_brief', 'send_time', 'brief', 'file', 'view_num', 'sell_num', 'status', 'sort'],
   },
   show: {
     parameters: {

+ 26 - 0
app/model/base/point.js

@@ -0,0 +1,26 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 积分表明细
+const point = {
+  customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, //
+  point: { type: Number, required: false, zh: '积分' }, // 整数
+  time: { type: String, required: false, zh: '时间' }, //
+  status: { type: String, required: false, default: '0', zh: '状态' }, // 字典:point_status
+  source: { type: String, required: false, zh: '来源' }, // 字典:point_source
+  source_id: { type: String, required: false, zh: '来源id' }, //
+};
+const schema = new Schema(point, { toJSON: { getters: true, virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ customer: 1 });
+schema.index({ status: 1 });
+schema.index({ source_id: 1 });
+
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Point', schema, 'point');
+};

+ 33 - 0
app/model/base/user.js

@@ -0,0 +1,33 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
+
+// 顾客
+const user = {
+  name: { type: String, required: false, zh: '用户名' }, //
+  phone: { type: String, required: false, zh: '手机号' }, //
+  password: { type: Secret, required: false, select: false, zh: '密码' }, //
+  icon: { type: Array, required: false, zh: '头像' }, //
+  birth: { type: String, required: false, zh: '生日' }, //
+  gender: { type: String, required: false, zh: '性别' }, // 字典:gender
+  email: { type: String, required: false, zh: '电子邮箱' }, //
+  openid: { type: String, required: false, zh: '微信小程序' }, //
+  status: { type: String, required: false, default: '0', zh: '状态' }, // 字典status_status
+};
+const schema = new Schema(user, { toJSON: { getters: true, virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ name: 1 });
+schema.index({ phone: 1 });
+schema.index({ gender: 1 });
+schema.index({ openid: 1 });
+schema.index({ status: 1 });
+
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('User', schema, 'user');
+};

+ 1 - 0
app/model/zrGoods.js

@@ -8,6 +8,7 @@ const MoneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-pl
 const zrGoods = {
   shop: { type: String, required: false, zh: '店铺', ref: 'Base.Shop' }, //
   name: { type: String, required: false, zh: '商品名称' }, //
+  num: { type: Number, required: false, zh: '库存' }, //
   shot_brief: { type: String, required: false, zh: '简短简介' }, //
   send_time: { type: String, required: false, zh: '发货时间' }, //
   brief: { type: String, required: false, zh: '商品介绍' }, //