Browse Source

add ai assistant

visuddhinanda 1 year ago
parent
commit
fef722b32d
1 changed files with 12 additions and 0 deletions
  1. 12 0
      api-v8/app/Http/Api/UserApi.php

+ 12 - 0
api-v8/app/Http/Api/UserApi.php

@@ -2,6 +2,8 @@
 
 namespace App\Http\Api;
 
+use App\Http\Resources\AiAssistant;
+use App\Models\AiModel;
 use App\Models\UserInfo;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Storage;
@@ -35,6 +37,9 @@ class UserApi
     public static function getByUuid($id)
     {
         $user = UserInfo::where('userid', $id)->first();
+        if (!$user) {
+            return AiAssistantApi::getByUuid($id);
+        }
         return UserApi::userInfo($user);
     }
     public static function getListByUuid($uuid)
@@ -43,6 +48,7 @@ class UserApi
             return null;
         };
         $users = UserInfo::whereIn('userid', $uuid)->get();
+        $assistants = AiModel::whereIn('uid', $uuid)->get();
         $output = array();
         foreach ($uuid as $key => $id) {
             foreach ($users as $user) {
@@ -51,6 +57,12 @@ class UserApi
                     continue;
                 };
             }
+            foreach ($assistants as $assistant) {
+                if ($assistant->uid === $id) {
+                    $output[] = AiAssistantApi::userInfo($assistant);
+                    continue;
+                };
+            }
         }
         return $output;
     }