guhongwei 4 years ago
parent
commit
45ea27e79c
2 changed files with 9 additions and 3 deletions
  1. 1 2
      app/service/user.js
  2. 8 1
      config/config.default.js

+ 1 - 2
app/service/user.js

@@ -12,7 +12,6 @@ class UserService extends CrudService {
     super(ctx, 'user');
     super(ctx, 'user');
     this.model = this.ctx.model.User;
     this.model = this.ctx.model.User;
     this.rmodel = this.ctx.model.Role;
     this.rmodel = this.ctx.model.Role;
-    this.productmodel = this.ctx.app.config.axios.product;
   }
   }
 
 
   // 重写创建方法
   // 重写创建方法
@@ -183,7 +182,7 @@ class UserService extends CrudService {
   async delete({ id }) {
   async delete({ id }) {
     const res = await this.model.update({ _id: ObjectId(id) }, { isdel: '1' });
     const res = await this.model.update({ _id: ObjectId(id) }, { isdel: '1' });
     if (res) {
     if (res) {
-      const arr = await this.productmodel.updateMany({ userid: ObjectId(id) }, { isdel: '1' });
+      const arr = await this.ctx.app.config.axios.product.model.updateMany({ userid: ObjectId(id) }, { isdel: '1' });
       if (arr) {
       if (arr) {
         return arr;
         return arr;
       }
       }

+ 8 - 1
config/config.default.js

@@ -12,7 +12,7 @@ module.exports = appInfo => {
    * built-in config
    * built-in config
    * @type {Egg.EggAppConfig}
    * @type {Egg.EggAppConfig}
    **/
    **/
-  const config = exports = {};
+  const config = (exports = {});
 
 
   // use for cookie sign key, should change to your own and keep security
   // use for cookie sign key, should change to your own and keep security
   config.keys = appInfo.name + '_1587024572540_7742';
   config.keys = appInfo.name + '_1587024572540_7742';
@@ -31,6 +31,13 @@ module.exports = appInfo => {
       port: 9999,
       port: 9999,
     },
     },
   };
   };
+  // axios service config
+  config.axios = {
+    product: {
+      // 产品
+      baseUrl: 'http://localhost:9004/api/market/product',
+    },
+  };
 
 
   config.wxapi = {
   config.wxapi = {
     appid: 'wxdf3ed83c095be97a', // 微信公众号APPID
     appid: 'wxdf3ed83c095be97a', // 微信公众号APPID