Sfoglia il codice sorgente

判断针对分站/非分站条件

lrf 3 anni fa
parent
commit
189286e21a
1 ha cambiato i file con 10 aggiunte e 4 eliminazioni
  1. 10 4
      lib/service/crud-service.js

+ 10 - 4
lib/service/crud-service.js

@@ -66,8 +66,11 @@ class CrudService extends NafService {
     let condition = cloneDeep(filter);
     // 分站模式确认
     condition = this.dealFilter(condition);
-    const _tenant = this.isMultiTenancy();
-    if (_tenant) condition._tenant = _tenant;
+    const isOpenMultiTenancy = get(this.app, 'plugins.multiTenancy');
+    if (isOpenMultiTenancy) {
+      const _tenant = this.isMultiTenancy();
+      if (_tenant) condition._tenant = _tenant;
+    }
     const pipeline = [{ $match: condition }];
     // 先排序
     if (sort) pipeline.push({ $sort: sort });
@@ -87,8 +90,11 @@ class CrudService extends NafService {
     let condition = cloneDeep(filter);
     condition = this.dealFilter(condition);
     // 分站模式确认
-    const _tenant = this.isMultiTenancy();
-    if (_tenant) condition._tenant = _tenant;
+    const isOpenMultiTenancy = get(this.app, 'plugins.multiTenancy');
+    if (isOpenMultiTenancy) {
+      const _tenant = this.isMultiTenancy();
+      if (_tenant) condition._tenant = _tenant;
+    }
     let count = 0;
     const res = await this.model.aggregate([{ $match: condition }, { $count: 'id' }]);
     if (res && isArray(res)) {