visuddhinanda hace 2 meses
padre
commit
a439b95ccf

+ 30 - 0
api-v12/app/Http/Requests/ChatMessageRequest.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class ChatMessageRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return false;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            //
+        ];
+    }
+}

+ 30 - 0
api-v12/app/Http/Requests/ChatRequest.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class ChatRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return false;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            //
+        ];
+    }
+}

+ 44 - 0
api-v12/app/Http/Requests/CollectionRequest.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class CollectionRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            /*
+            string Id        = 1;
+            string Title     = 2;
+            string Subtitle  = 3;
+            string Summary   = 4;
+            string ArticleList   = 5;
+            repeated Tag Tags = 6;
+
+            string Lang = 51;
+            string EditorId = 52;
+            EnumPublicity Publicity = 53;
+             */
+            'id' => 'required|unique:posts',
+            'title' => 'required|max:512',
+            'subtitle' => 'nullable|max:512',
+        ];
+    }
+}

+ 30 - 0
api-v12/app/Http/Requests/StoreAiModelRequest.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class StoreAiModelRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            //
+        ];
+    }
+}

+ 30 - 0
api-v12/app/Http/Requests/StoreAttachmentMapRequest.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class StoreAttachmentMapRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return false;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            //
+        ];
+    }
+}

+ 51 - 0
api-v12/app/Http/Requests/StoreChatMessageRequest.php

@@ -0,0 +1,51 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+use Illuminate\Validation\Rule;
+
+class StoreChatMessageRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            'chat_id' => 'required|string|size:36',
+            'messages' => 'required|array|min:1',
+            'messages.*.parent_id' => 'nullable|string|exists:chat_messages,uid',
+            'messages.*.session_id' => 'nullable|string|size:36',
+            'messages.*.role' => ['required', Rule::in(['user', 'assistant', 'tool'])],
+            'messages.*.content' => 'nullable|string',
+            'messages.*.model_name' => 'nullable|string|max:100',
+            'messages.*.tool_calls' => 'nullable|array',
+            'messages.*.tool_calls.*.id' => 'required_with:tool_calls|string',
+            'messages.*.tool_calls.*.function' => 'required_with:tool_calls|string',
+            'messages.*.tool_calls.*.arguments' => 'required_with:tool_calls',
+            'messages.*.tool_call_id' => 'nullable|string|max:100'
+        ];
+    }
+
+    public function messages()
+    {
+        return [
+            'messages.required' => '批量更新的消息列表不能为空',
+            'messages.*.parent_id.required' => '消息ID不能为空',
+            'messages.*.parent_id.exists' => '消息不存在'
+        ];
+    }
+}

+ 30 - 0
api-v12/app/Http/Requests/StoreChatRequest.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class StoreChatRequest extends FormRequest
+{
+    public function authorize()
+    {
+        return true;
+    }
+
+    public function rules()
+    {
+        return [
+            'title' => 'required|string|max:255',
+            'user_id' => 'required|string|exists:user_infos,userid'
+        ];
+    }
+
+    public function messages()
+    {
+        return [
+            'title.required' => '聊天标题不能为空',
+            'title.max' => '聊天标题不能超过255个字符',
+            'user_id.exists' => '用户不存在'
+        ];
+    }
+}

+ 48 - 0
api-v12/app/Http/Requests/StoreDiscussionRequest.php

@@ -0,0 +1,48 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+use App\Http\Api\AuthApi;
+use Illuminate\Support\Facades\Log;
+
+class StoreDiscussionRequest extends FormRequest
+{
+    private $user;
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        $user = AuthApi::current($this);
+        if (!$user) {
+            Log::warning('discussion store auth failed', ['request' => $this]);
+            return false;
+        }
+        $this->user = $user;
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules(): array
+    {
+        return [
+            'res_id' => 'required|string',
+            'res_type' => 'required|string',
+        ];
+    }
+
+    public function messages(): array
+    {
+        return [
+            'res_id.required' => 'res_type是必填项',
+            'res_type.required' => 'type是必填项',
+        ];
+    }
+}

+ 30 - 0
api-v12/app/Http/Requests/StoreSentenceAttachmentRequest.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class StoreSentenceAttachmentRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return false;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            //
+        ];
+    }
+}

+ 30 - 0
api-v12/app/Http/Requests/UpdateAiModelRequest.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class UpdateAiModelRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            //
+        ];
+    }
+}

+ 30 - 0
api-v12/app/Http/Requests/UpdateAttachmentMapRequest.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class UpdateAttachmentMapRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return false;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            //
+        ];
+    }
+}

+ 32 - 0
api-v12/app/Http/Requests/UpdateChatMessageRequest.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class UpdateChatMessageRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            'content' => 'sometimes|string',
+            'is_active' => 'sometimes|boolean',
+            'model_name' => 'sometimes|string|max:100'
+        ];
+    }
+}

+ 30 - 0
api-v12/app/Http/Requests/UpdateChatRequest.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class UpdateChatRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            'title' => 'sometimes|string|max:255'
+        ];
+    }
+}

+ 30 - 0
api-v12/app/Http/Requests/UpdateSentenceAttachmentRequest.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class UpdateSentenceAttachmentRequest extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     *
+     * @return bool
+     */
+    public function authorize()
+    {
+        return false;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array
+     */
+    public function rules()
+    {
+        return [
+            //
+        ];
+    }
+}