✨ 增加策略列表接口,接口支持上传时指定策略
This commit is contained in:
20
app/Http/Controllers/Api/V1/StrategyController.php
Normal file
20
app/Http/Controllers/Api/V1/StrategyController.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Group;
|
||||
use App\Models\Strategy;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class StrategyController extends Controller
|
||||
{
|
||||
public function index(): Response
|
||||
{
|
||||
/** @var Group $group */
|
||||
$group = Auth::check() ? Auth::user()->group : Group::query()->where('is_guest', true)->first();
|
||||
$strategies = $group->strategies()->get()->each(fn (Strategy $strategy) => $strategy->setVisible(['id', 'name']));
|
||||
return $this->success('success', compact('strategies'));
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
|
||||
@@ -318,6 +318,91 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="text-xl mb-2 text-gray-800 font-semibold">策略相关</p>
|
||||
<div class="space-y-4 bg-white p-3 rounded-md mb-10">
|
||||
<div>
|
||||
<p class="text-lg text-gray-700 font-semibold">策略列表</p>
|
||||
<x-code><span class="text-sky-500 select-none">GET </span>/strategies</x-code>
|
||||
|
||||
<div class="my-4 overflow-x-auto">
|
||||
<p class="text-sm mb-2">请求参数(Query)</p>
|
||||
<table class="min-w-full">
|
||||
<thead class="bg-white border">
|
||||
<tr>
|
||||
<th scope="col" class="px-3 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap">
|
||||
字段
|
||||
</th>
|
||||
<th scope="col" class="px-3 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap">
|
||||
类型
|
||||
</th>
|
||||
<th scope="col" class="px-3 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap">
|
||||
说明
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white border divide-y text-sm">
|
||||
<tr>
|
||||
<td class="px-3 py-2 whitespace-nowrap">keyword</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">String</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">筛选关键字</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="my-4 overflow-x-auto">
|
||||
<p class="text-sm mb-2">返回参数</p>
|
||||
<table class="min-w-full">
|
||||
<thead class="bg-white border">
|
||||
<tr>
|
||||
<th scope="col" class="px-3 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap">
|
||||
字段
|
||||
</th>
|
||||
<th scope="col" class="px-3 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap">
|
||||
类型
|
||||
</th>
|
||||
<th scope="col" class="px-3 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap">
|
||||
说明
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white border divide-y text-sm">
|
||||
<tr>
|
||||
<td class="px-3 py-2 whitespace-nowrap">status</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">Boolean</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">状态,true 或 false</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-3 py-2 whitespace-nowrap">message</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">String</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">描述信息</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-3 py-2 whitespace-nowrap">data</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">Object</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">数据</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-3 py-2 whitespace-nowrap pl-6">strategies</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">Object[]</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">策略数据</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-3 py-2 whitespace-nowrap pl-10">id</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">Integer</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">策略 ID</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-3 py-2 whitespace-nowrap pl-10">name</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">String</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">策略名称</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="text-xl mb-2 text-gray-800 font-semibold">图片相关</p>
|
||||
<div class="space-y-4 bg-white p-3 rounded-md mb-10">
|
||||
<div>
|
||||
@@ -372,6 +457,11 @@
|
||||
<td class="px-3 py-2 whitespace-nowrap">File</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">图片文件</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-3 py-2 whitespace-nowrap">strategy_id</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">Integer</td>
|
||||
<td class="px-3 py-2 whitespace-nowrap">储存策略ID</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -922,8 +1012,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
|
||||
@endpush
|
||||
</x-app-layout>
|
||||
|
||||
@@ -5,6 +5,7 @@ use App\Http\Controllers\Api\V1\ImageController;
|
||||
use App\Http\Controllers\Api\V1\AlbumController;
|
||||
use App\Http\Controllers\Api\V1\TokenController;
|
||||
use App\Http\Controllers\Api\V1\UserController;
|
||||
use App\Http\Controllers\Api\V1\StrategyController;
|
||||
use App\Http\Middleware\CheckIsEnableApi;
|
||||
|
||||
/*
|
||||
@@ -22,6 +23,7 @@ Route::group([
|
||||
'prefix' => 'v1',
|
||||
'middleware' => CheckIsEnableApi::class,
|
||||
], function () {
|
||||
Route::get('strategies', [StrategyController::class, 'index']);
|
||||
Route::post('upload', [ImageController::class, 'upload']);
|
||||
Route::post('tokens', [TokenController::class, 'store'])->middleware('throttle:3,1');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user