ソースを参照

更新,将默认全局查询更变为默认分站

lrf 3 年 前
コミット
79a95a28ec

+ 10 - 2
app/extend/application.js

@@ -1,5 +1,13 @@
 'use strict';
-
+let colors = require('colors');
 module.exports = {
-
+  log(word) {
+    console.log(colors.brightBlue.italic.underline(word));
+  },
+  logSuccess(word) {
+    console.log(colors.brightGreen.italic.underline(word));
+  },
+  logError(word) {
+    console.log(colors.brightRed.italic.underline(word));
+  },
 };

+ 2 - 2
lib/plugin/egg-multi-tenancy/app/extend/application.js

@@ -30,7 +30,7 @@ const multiTenancyPlugin = (schema, options = {}) => {
 
   schema.pre('save', async function() {
     const tenant = schema.get('x-tenant');
-    if (tenant !== 'global') {
+    if (tenant !== 'defaultTenant') {
       this._tenant = schema.get('x-tenant');
     }
   });
@@ -39,7 +39,7 @@ const multiTenancyPlugin = (schema, options = {}) => {
   querys.forEach(action => {
     schema.pre(action, async function() {
       const tenant = schema.get('x-tenant');
-      if (tenant !== 'global') {
+      if (tenant !== 'defaultTenant') {
         this.where('_tenant').equals(schema.get('x-tenant'));
       }
     });

+ 3 - 2
package.json

@@ -4,6 +4,7 @@
   "description": "naf egg framework use mongoose - free version",
   "dependencies": {
     "axios": "^0.19.0",
+    "colors": "^1.4.0",
     "egg": "^2.23.0",
     "egg-mongoose": "^3.2.0",
     "egg-scripts": "^2.11.0",
@@ -24,8 +25,8 @@
     "eslint": "^6.5.1",
     "eslint-config-egg": "^7.5.1",
     "eslint-config-naf": "^0.0.6",
-    "webstorm-disable-index": "^1.2.0",
-    "jsonwebtoken": "^8.5.1"
+    "jsonwebtoken": "^8.5.1",
+    "webstorm-disable-index": "^1.2.0"
   },
   "engines": {
     "node": ">=8.9.0"