lrf 2 years ago
parent
commit
98b45ced6f

+ 1 - 1
app/model/system/config.js

@@ -4,7 +4,7 @@ const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
 const configProp = {
   logo: { type: Array, zh: 'logo' },
   share: { type: Array, zh: '分享图片' },
-  buyPoint: { type: Number, zh: '购物赠送积分' },
+  buyPoint: { type: Number, zh: '购物赠送积分' }, // 金额 / buyPoint 为实际获得积分
   pointPlan: { type: Array, zh: '积分计划' }, // 后续有待制作,目前全靠新写
 };
 // 系统设置

+ 4 - 0
app/public/defaultData/config.js

@@ -0,0 +1,4 @@
+module.exports = {
+  title: '天恩活泉',
+  config: { buyPoint: 10 },
+};

+ 5 - 1
app/service/system/config.js

@@ -4,12 +4,16 @@ const { BusinessError, ErrorCode } = require('naf-core').Error;
 const _ = require('lodash');
 const assert = require('assert');
 
-// 
+//
 class ConfigService extends CrudService {
   constructor(ctx) {
     super(ctx, 'config');
     this.model = this.ctx.model.System.Config;
   }
+  async index() {
+    const data = await this.model.findOne({});
+    return data;
+  }
 }
 
 module.exports = ConfigService;

+ 10 - 0
app/service/util/install.js

@@ -18,6 +18,16 @@ class InstallService extends CrudService {
     // await this.initSelfShop();
     // await this.initTestCustomer();
     // await this.initGoodsTags();
+    await this.initConfig();
+  }
+
+  async initConfig() {
+    const model = this.ctx.model.System.Config;
+    const num = await model.count({});
+    if (num > 0) return;
+    const p = path.resolve(this.dataIndex, 'config.js');
+    const data = require(p);
+    await model.create(data);
   }
 
   async initGoodsTags() {

+ 1 - 0
config/config.default.js

@@ -43,6 +43,7 @@ module.exports = appInfo => {
       useNewUrlParser: true,
       useCreateIndex: true,
       useFindAndModify: true,
+      allowDiskUse: true,
     },
   };
   // jwt设置