Skip to content

Commit

Permalink
Fix: #72 사진생성실패 목업알람 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
BYEONGRYEOL committed Aug 24, 2024
1 parent 0a4b22e commit 3b3fd70
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.gt.genti.model.LogItem;
import com.gt.genti.model.LogRequester;
import com.gt.genti.model.Logging;
import com.gt.genti.picturegeneraterequest.service.PictureGenerateFailedEventPublisher;
import com.gt.genti.picturegenerateresponse.service.PGRESCompleteEventPublisher;
import com.gt.genti.user.model.OauthPlatform;
import com.gt.genti.user.model.UserRole;
Expand All @@ -49,6 +50,7 @@ public class AuthController implements AuthApi {
private final JwtTokenProvider jwtTokenProvider;
private final AuthService authService;
private final PGRESCompleteEventPublisher pGRESCompleteEventPublisher;
private final PictureGenerateFailedEventPublisher pictureGenerateFailedEventPublisher;

@GetMapping("/login/oauth2")
@Logging(item = LogItem.OAUTH_WEB, action = LogAction.LOGIN, requester = LogRequester.ANONYMOUS)
Expand Down Expand Up @@ -107,8 +109,14 @@ public ResponseEntity<ApiResult<TokenResponse>> reissue(

@PostMapping("/fcmtest/userId/{userId}")
public ResponseEntity<ApiResult<Boolean>> fcmtest(
@RequestParam(name = "success") String success,
@PathVariable Long userId) {
pGRESCompleteEventPublisher.publishPictureGenerateCompleteEvent(userId);

if ("success".equals(success)) {
pGRESCompleteEventPublisher.publishPictureGenerateCompleteEvent(userId);
} else {
pictureGenerateFailedEventPublisher.publishPictureGenerateFailedEvent(userId);
}
return success(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.gt.genti.picturegeneraterequest.service;

import org.springframework.context.ApplicationEventPublisher;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.gt.genti.firebase.event.PictureGenerationFailedNotificationEvent;

import lombok.RequiredArgsConstructor;

@Service
@RequiredArgsConstructor
public class PictureGenerateFailedEventPublisher {

private final ApplicationEventPublisher eventPublisher;

@Async
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void publishPictureGenerateFailedEvent(Long receiverId) {
eventPublisher.publishEvent(PictureGenerationFailedNotificationEvent.of(receiverId));
}

}

0 comments on commit 3b3fd70

Please sign in to comment.