-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: SlackNotification 어노테이션 기반으로 수정
- Loading branch information
Showing
4 changed files
with
51 additions
and
33 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/main/java/com/moabam/global/common/annotation/SlackNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.moabam.global.common.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target({ElementType.METHOD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface SlackNotification { | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/com/moabam/global/common/util/SlackNotificationAspect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.moabam.global.common.util; | ||
|
||
import org.aspectj.lang.ProceedingJoinPoint; | ||
import org.aspectj.lang.annotation.Around; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.moabam.api.infrastructure.slack.SlackService; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Aspect | ||
@Component | ||
@Profile({"dev", "prod"}) | ||
@RequiredArgsConstructor | ||
public class SlackNotificationAspect { | ||
|
||
private final SlackService slackService; | ||
|
||
@Around("@annotation(com.moabam.global.common.annotation.SlackNotification) && args(request, exception)") | ||
public Object sendSlack(ProceedingJoinPoint joinPoint, HttpServletRequest request, Exception exception) | ||
throws Throwable { | ||
slackService.send(request, exception); | ||
|
||
return joinPoint.proceed(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
src/main/java/com/moabam/global/error/handler/SlackExceptionHandler.java
This file was deleted.
Oops, something went wrong.