feat: 增强管理员权限管理,添加 RBAC 支持,更新 AdminUser 模型以处理角色和权限,更新登录接口返回权限信息,扩展数据库填充器以同步角色权限
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Admin\Reconcile;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\AdminUser;
|
||||
use App\Services\Admin\AdminReconcileJobService;
|
||||
use App\Support\ApiResponse;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/** POST /api/v1/admin/reconcile-jobs */
|
||||
final class ReconcileJobStoreController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, AdminReconcileJobService $service): JsonResponse
|
||||
{
|
||||
/** @var AdminUser $admin */
|
||||
$admin = $request->lotteryAdmin();
|
||||
|
||||
$data = validator($request->all(), [
|
||||
'reconcile_type' => ['required', 'string', 'max:32'],
|
||||
'period_start' => ['nullable', 'date'],
|
||||
'period_end' => ['nullable', 'date', 'after_or_equal:period_start'],
|
||||
'items' => ['nullable', 'array', 'max:5000'],
|
||||
'items.*.side_a_ref' => ['nullable', 'string', 'max:128'],
|
||||
'items.*.side_b_ref' => ['nullable', 'string', 'max:128'],
|
||||
'items.*.difference_amount' => ['nullable', 'integer'],
|
||||
'items.*.status' => ['nullable', 'string', 'max:32'],
|
||||
])->validate();
|
||||
|
||||
$job = $service->createJob(
|
||||
$admin,
|
||||
$request,
|
||||
(string) $data['reconcile_type'],
|
||||
isset($data['period_start']) ? Carbon::parse((string) $data['period_start']) : null,
|
||||
isset($data['period_end']) ? Carbon::parse((string) $data['period_end']) : null,
|
||||
isset($data['items']) ? (array) $data['items'] : null,
|
||||
);
|
||||
|
||||
return ApiResponse::success([
|
||||
'id' => (int) $job->id,
|
||||
'job_no' => $job->job_no,
|
||||
'status' => $job->status,
|
||||
'summary_json' => $job->summary_json,
|
||||
'item_count' => $job->items()->count(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user