- TodayIssue 모델 및 마이그레이션 추가 - TodayIssueController, TodayIssueService 구현 - TodayIssueObserverService 및 Observer 패턴 적용 - DailyReportService 연동 - Swagger API 문서 업데이트 - 라우트 추가
78 lines
2.1 KiB
PHP
78 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
use App\Helpers\ApiResponse;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\TodayIssueService;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class TodayIssueController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly TodayIssueService $todayIssueService
|
|
) {}
|
|
|
|
/**
|
|
* 오늘의 이슈 리스트 조회
|
|
*/
|
|
public function summary(Request $request): JsonResponse
|
|
{
|
|
$limit = (int) $request->input('limit', 30);
|
|
|
|
return ApiResponse::handle(function () use ($limit) {
|
|
return $this->todayIssueService->summary($limit);
|
|
}, __('message.fetched'));
|
|
}
|
|
|
|
/**
|
|
* 읽지 않은 이슈 목록 조회 (헤더 알림용)
|
|
*/
|
|
public function unread(Request $request): JsonResponse
|
|
{
|
|
$limit = (int) $request->input('limit', 10);
|
|
|
|
return ApiResponse::handle(function () use ($limit) {
|
|
return $this->todayIssueService->getUnreadList($limit);
|
|
}, __('message.fetched'));
|
|
}
|
|
|
|
/**
|
|
* 읽지 않은 이슈 개수 조회 (헤더 알림 뱃지용)
|
|
*/
|
|
public function unreadCount(): JsonResponse
|
|
{
|
|
return ApiResponse::handle(function () {
|
|
return ['count' => $this->todayIssueService->getUnreadCount()];
|
|
}, __('message.fetched'));
|
|
}
|
|
|
|
/**
|
|
* 이슈 읽음 처리
|
|
*/
|
|
public function markAsRead(int $id): JsonResponse
|
|
{
|
|
return ApiResponse::handle(function () use ($id) {
|
|
$result = $this->todayIssueService->markAsRead($id);
|
|
if (! $result) {
|
|
throw new \App\Exceptions\ApiException(__('error.not_found'), 404);
|
|
}
|
|
|
|
return null;
|
|
}, __('message.today_issue.marked_as_read'));
|
|
}
|
|
|
|
/**
|
|
* 모든 이슈 읽음 처리
|
|
*/
|
|
public function markAllAsRead(): JsonResponse
|
|
{
|
|
return ApiResponse::handle(function () {
|
|
$count = $this->todayIssueService->markAllAsRead();
|
|
|
|
return ['count' => $count];
|
|
}, __('message.today_issue.all_marked_as_read'));
|
|
}
|
|
}
|