diff --git a/app/Http/Controllers/Api/V1/TodayIssueController.php b/app/Http/Controllers/Api/V1/TodayIssueController.php index e25eff5..c510953 100644 --- a/app/Http/Controllers/Api/V1/TodayIssueController.php +++ b/app/Http/Controllers/Api/V1/TodayIssueController.php @@ -20,9 +20,10 @@ public function __construct( public function summary(Request $request): JsonResponse { $limit = (int) $request->input('limit', 30); + $date = $request->input('date'); // YYYY-MM-DD (이전 이슈 조회용) - return ApiResponse::handle(function () use ($limit) { - return $this->todayIssueService->summary($limit); + return ApiResponse::handle(function () use ($limit, $date) { + return $this->todayIssueService->summary($limit, null, $date); }, __('message.fetched')); } diff --git a/app/Services/TodayIssueService.php b/app/Services/TodayIssueService.php index 6a801fd..93f5139 100644 --- a/app/Services/TodayIssueService.php +++ b/app/Services/TodayIssueService.php @@ -17,30 +17,42 @@ class TodayIssueService extends Service * * @param int $limit 조회할 최대 항목 수 (기본 30) * @param string|null $badge 뱃지 필터 (null이면 전체) + * @param string|null $date 조회 날짜 (YYYY-MM-DD, null이면 오늘) */ - public function summary(int $limit = 30, ?string $badge = null): array + public function summary(int $limit = 30, ?string $badge = null, ?string $date = null): array { $tenantId = $this->tenantId(); $userId = $this->apiUserId(); + // date 파라미터가 있으면 해당 날짜, 없으면 오늘 + $targetDate = $date ? Carbon::parse($date) : today(); + $query = TodayIssue::query() ->where('tenant_id', $tenantId) ->forUser($userId) // 본인 대상 또는 전체 브로드캐스트 - ->active() // 만료되지 않은 이슈만 - ->today() // 오늘 날짜 이슈만 + ->whereDate('created_at', $targetDate) ->orderByDesc('created_at'); + // 이전 이슈 조회 시에는 만료 필터 무시 (과거 데이터도 조회 가능) + if (! $date) { + $query->active(); // 오늘 이슈만 만료 필터 적용 + } + // 뱃지 필터 if ($badge !== null && $badge !== 'all') { $query->byBadge($badge); } - // 전체 개수 (필터 적용 전, 오늘 날짜만) + // 전체 개수 (필터 적용 전) $totalQuery = TodayIssue::query() ->where('tenant_id', $tenantId) ->forUser($userId) - ->active() - ->today(); + ->whereDate('created_at', $targetDate); + + if (! $date) { + $totalQuery->active(); + } + $totalCount = $totalQuery->count(); // 결과 조회 diff --git a/package-lock.json b/package-lock.json index 6898565..bb18a55 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "api", + "name": "sam-api", "lockfileVersion": 3, "requires": true, "packages": {