Ken 3 weeks ago
parent
commit
fa355ac9cb
1 changed files with 12 additions and 2 deletions
  1. 12 2
      app/Services/ConfigService.php

+ 12 - 2
app/Services/ConfigService.php

@@ -57,6 +57,15 @@ class ConfigService extends BaseService
         return $where;
     }
 
+    public static function getWhereIn(array $search = []): array
+    {
+        $where = [];
+        if (isset($search['in_group_id']) && is_array($search['in_group_id'])) {
+            $where['group_id'] = $search['in_group_id'];
+        }
+        return $where;
+    }
+
 
     /**
      * @description: 查询单条数据
@@ -87,8 +96,9 @@ class ConfigService extends BaseService
     {
         $limit = isset($search['limit']) ? $search['limit'] : 15;
         $query = self::model()::where(self::getWhere($search));
-        if (isset($search['in_group_id']) && is_array($search['in_group_id'])) {
-            $query = $query->whereIn('group_id', $search['in_group_id']);
+        $where = self::getWhereIn($search);
+        foreach ($where as $key => $value) {
+            $query = $query->whereIn($key, $search['in_group_id']);
         }
         $paginator = $query->paginate($limit);
         return ['total' => $paginator->total(), 'data' => $paginator->items()];