feat: 增强管理员权限管理,添加 RBAC 支持,更新 AdminUser 模型以处理角色和权限,更新登录接口返回权限信息,扩展数据库填充器以同步角色权限
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Admin\Reconcile;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ReconcileItem;
|
||||
use App\Models\ReconcileJob;
|
||||
use App\Support\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/** GET /api/v1/admin/reconcile-jobs/{reconcile_job}/items */
|
||||
final class ReconcileItemIndexController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, ReconcileJob $reconcile_job): JsonResponse
|
||||
{
|
||||
$perPage = min(max((int) $request->integer('per_page', 50), 1), 200);
|
||||
$page = max((int) $request->integer('page', 1), 1);
|
||||
|
||||
$paginator = $reconcile_job->items()
|
||||
->orderBy('id')
|
||||
->paginate($perPage, ['*'], 'page', $page);
|
||||
|
||||
return ApiResponse::success([
|
||||
'job_id' => (int) $reconcile_job->id,
|
||||
'job_no' => $reconcile_job->job_no,
|
||||
'items' => collect($paginator->items())->map(fn (ReconcileItem $r) => [
|
||||
'id' => (int) $r->id,
|
||||
'side_a_ref' => $r->side_a_ref,
|
||||
'side_b_ref' => $r->side_b_ref,
|
||||
'difference_amount' => (int) $r->difference_amount,
|
||||
'status' => $r->status,
|
||||
'resolved_at' => $r->resolved_at?->toIso8601String(),
|
||||
'created_at' => $r->created_at?->toIso8601String(),
|
||||
])->all(),
|
||||
'meta' => [
|
||||
'current_page' => $paginator->currentPage(),
|
||||
'per_page' => $paginator->perPage(),
|
||||
'total' => $paginator->total(),
|
||||
'last_page' => $paginator->lastPage(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user