feat: 대시보드 API 및 FCM 푸시 알림 API 구현
Dashboard API:
- DashboardController, DashboardService 추가
- /dashboard/summary, /charts, /approvals 엔드포인트
Push Notification API:
- FCM 토큰 관리 (등록/해제/목록)
- 알림 설정 관리 (유형별 on/off, 알림음 설정)
- 알림 유형: deposit, withdrawal, order, approval, attendance, notice, system
- 알림음: default, deposit, withdrawal, order, approval, urgent
- PushDeviceToken, PushNotificationSetting 모델
- Swagger 문서 추가
2025-12-18 11:16:24 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
|
|
feat: Phase 5 API 개발 완료 (사용자 초대, 알림설정, 계정관리, 거래명세서)
5.1 사용자 초대 기능:
- UserInvitation 마이그레이션, 모델, 서비스, 컨트롤러, Swagger
- 초대 발송/수락/취소/재발송 API
5.2 알림설정 확장:
- NotificationSetting 마이그레이션, 모델, 서비스, 컨트롤러, Swagger
- 채널별/유형별 알림 설정 관리
5.3 계정정보 수정 API:
- 회원탈퇴, 사용중지, 약관동의 관리
- AccountService, AccountController, Swagger
5.4 매출 거래명세서 API:
- 거래명세서 조회/발행/이메일발송
- SaleService 확장, Swagger 문서화
2025-12-19 14:52:53 +09:00
|
|
|
use App\Helpers\ApiResponse;
|
feat: 대시보드 API 및 FCM 푸시 알림 API 구현
Dashboard API:
- DashboardController, DashboardService 추가
- /dashboard/summary, /charts, /approvals 엔드포인트
Push Notification API:
- FCM 토큰 관리 (등록/해제/목록)
- 알림 설정 관리 (유형별 on/off, 알림음 설정)
- 알림 유형: deposit, withdrawal, order, approval, attendance, notice, system
- 알림음: default, deposit, withdrawal, order, approval, urgent
- PushDeviceToken, PushNotificationSetting 모델
- Swagger 문서 추가
2025-12-18 11:16:24 +09:00
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use App\Http\Requests\Push\RegisterTokenRequest;
|
|
|
|
|
use App\Http\Requests\Push\UpdateSettingsRequest;
|
|
|
|
|
use App\Services\PushNotificationService;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
|
|
class PushNotificationController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* FCM 토큰 등록
|
|
|
|
|
*/
|
|
|
|
|
public function registerToken(RegisterTokenRequest $request)
|
|
|
|
|
{
|
|
|
|
|
return ApiResponse::handle(function () use ($request) {
|
|
|
|
|
$service = new PushNotificationService;
|
|
|
|
|
|
|
|
|
|
return $service->registerToken($request->validated());
|
|
|
|
|
}, __('message.push.token_registered'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* FCM 토큰 해제
|
|
|
|
|
*/
|
|
|
|
|
public function unregisterToken(Request $request)
|
|
|
|
|
{
|
|
|
|
|
return ApiResponse::handle(function () use ($request) {
|
|
|
|
|
$token = $request->input('token');
|
|
|
|
|
if (! $token) {
|
|
|
|
|
throw new \InvalidArgumentException(__('error.push.token_required'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$service = new PushNotificationService;
|
|
|
|
|
|
|
|
|
|
return ['unregistered' => $service->unregisterToken($token)];
|
|
|
|
|
}, __('message.push.token_unregistered'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 사용자의 등록된 디바이스 토큰 목록
|
|
|
|
|
*/
|
|
|
|
|
public function getTokens()
|
|
|
|
|
{
|
|
|
|
|
return ApiResponse::handle(function () {
|
|
|
|
|
$service = new PushNotificationService;
|
|
|
|
|
|
|
|
|
|
return $service->getUserTokens();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 알림 설정 조회
|
|
|
|
|
*/
|
|
|
|
|
public function getSettings()
|
|
|
|
|
{
|
|
|
|
|
return ApiResponse::handle(function () {
|
|
|
|
|
$service = new PushNotificationService;
|
|
|
|
|
|
|
|
|
|
return $service->getSettings();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 알림 설정 업데이트
|
|
|
|
|
*/
|
|
|
|
|
public function updateSettings(UpdateSettingsRequest $request)
|
|
|
|
|
{
|
|
|
|
|
return ApiResponse::handle(function () use ($request) {
|
|
|
|
|
$service = new PushNotificationService;
|
|
|
|
|
|
|
|
|
|
return $service->updateSettings($request->validated()['settings']);
|
|
|
|
|
}, __('message.push.settings_updated'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 알림 유형 목록 조회
|
|
|
|
|
*/
|
|
|
|
|
public function getNotificationTypes()
|
|
|
|
|
{
|
|
|
|
|
return ApiResponse::handle(function () {
|
|
|
|
|
return [
|
|
|
|
|
'types' => \App\Models\PushNotificationSetting::getAllTypes(),
|
|
|
|
|
'sounds' => \App\Models\PushNotificationSetting::getAllSounds(),
|
|
|
|
|
];
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-12-18 11:40:49 +09:00
|
|
|
}
|