Procházet zdrojové kódy

检查ai_models是否存在

visuddhinanda před 2 měsíci
rodič
revize
122822cd28
1 změnil soubory, kde provedl 13 přidání a 0 odebrání
  1. 13 0
      api-v12/app/Services/AIModelService.php

+ 13 - 0
api-v12/app/Services/AIModelService.php

@@ -11,12 +11,21 @@ class AIModelService
 
 
     public function getModelsById($id)
     public function getModelsById($id)
     {
     {
+        // 添加表存在检查
+        if (!\Illuminate\Support\Facades\Schema::hasTable('ai_models')) {
+            return [];
+        }
+
         $table = AiModel::whereIn('uid', $id);
         $table = AiModel::whereIn('uid', $id);
         $result = $table->get();
         $result = $table->get();
         return AiModelResource::collection(resource: $result);
         return AiModelResource::collection(resource: $result);
     }
     }
     public function getModelById($id)
     public function getModelById($id)
     {
     {
+        // 添加表存在检查
+        if (!\Illuminate\Support\Facades\Schema::hasTable('ai_models')) {
+            return [];
+        }
         $result = AiModel::where('uid', $id)
         $result = AiModel::where('uid', $id)
             ->first();
             ->first();
         return new AiModelResource(resource: $result);
         return new AiModelResource(resource: $result);
@@ -24,6 +33,10 @@ class AIModelService
 
 
     public function getSysModels($type = null)
     public function getSysModels($type = null)
     {
     {
+        // 添加表存在检查
+        if (!\Illuminate\Support\Facades\Schema::hasTable('ai_models')) {
+            return [];
+        }
         if (empty($type)) {
         if (empty($type)) {
             $types = ['wbw', 'chat', 'summarize'];
             $types = ['wbw', 'chat', 'summarize'];
         } else {
         } else {