feat: 增强管理员权限管理,添加 RBAC 支持,更新 AdminUser 模型以处理角色和权限,更新登录接口返回权限信息,扩展数据库填充器以同步角色权限
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Admin\Reconcile;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ReconcileJob;
|
||||
use App\Support\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/** GET /api/v1/admin/reconcile-jobs */
|
||||
final class ReconcileJobIndexController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$perPage = min(max((int) $request->integer('per_page', 25), 1), 100);
|
||||
$page = max((int) $request->integer('page', 1), 1);
|
||||
$type = trim((string) $request->query('reconcile_type', ''));
|
||||
|
||||
$q = ReconcileJob::query()->orderByDesc('id');
|
||||
if ($type !== '') {
|
||||
$q->where('reconcile_type', $type);
|
||||
}
|
||||
|
||||
$paginator = $q->paginate($perPage, ['*'], 'page', $page);
|
||||
|
||||
return ApiResponse::success([
|
||||
'items' => collect($paginator->items())->map(fn (ReconcileJob $j) => $this->row($j))->all(),
|
||||
'meta' => [
|
||||
'current_page' => $paginator->currentPage(),
|
||||
'per_page' => $paginator->perPage(),
|
||||
'total' => $paginator->total(),
|
||||
'last_page' => $paginator->lastPage(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function row(ReconcileJob $j): array
|
||||
{
|
||||
return [
|
||||
'id' => (int) $j->id,
|
||||
'job_no' => $j->job_no,
|
||||
'admin_user_id' => $j->admin_user_id !== null ? (int) $j->admin_user_id : null,
|
||||
'reconcile_type' => $j->reconcile_type,
|
||||
'status' => $j->status,
|
||||
'period_start' => $j->period_start?->toIso8601String(),
|
||||
'period_end' => $j->period_end?->toIso8601String(),
|
||||
'summary_json' => $j->summary_json,
|
||||
'finished_at' => $j->finished_at?->toIso8601String(),
|
||||
'created_at' => $j->created_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user