-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
181 additions
and
30 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
src/main/java/life/offonoff/ab/application/event/topic/TopicDeleteEvent.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,15 @@ | ||
package life.offonoff.ab.application.event.topic; | ||
|
||
import life.offonoff.ab.domain.topic.Topic; | ||
import lombok.Getter; | ||
import org.springframework.context.ApplicationEvent; | ||
|
||
@Getter | ||
public class TopicDeleteEvent { | ||
|
||
private final Topic topic; | ||
|
||
public TopicDeleteEvent(Topic topic) { | ||
this.topic = topic; | ||
} | ||
} |
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
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
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
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,9 @@ | ||
package life.offonoff.ab.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.EnableAspectJAutoProxy; | ||
|
||
@Configuration | ||
@EnableAspectJAutoProxy | ||
public class AopConfig { | ||
} |
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
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
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
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
2 changes: 1 addition & 1 deletion
2
...omain/comment/IllegalAuthorException.java → .../ab/exception/IllegalAuthorException.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
12 changes: 12 additions & 0 deletions
12
src/main/java/life/offonoff/ab/repository/notfication/NotificationJdbcRepository.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 life.offonoff.ab.repository.notfication; | ||
|
||
import life.offonoff.ab.domain.notification.VoteResultNotification; | ||
|
||
import java.util.List; | ||
|
||
public interface NotificationJdbcRepository { | ||
|
||
void saveVoteResultNotificationsInBatch(List<VoteResultNotification> notifications); | ||
|
||
void deleteAllByTopicId(Long topicId); | ||
} |
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
7 changes: 5 additions & 2 deletions
7
...sitory/notice/NotificationRepository.java → ...y/notfication/NotificationRepository.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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
package life.offonoff.ab.repository.notice; | ||
package life.offonoff.ab.repository.notfication; | ||
|
||
import life.offonoff.ab.domain.notification.Notification; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface NotificationRepository extends JpaRepository<Notification, Long>, NotificationRepositoryCustom { | ||
public interface NotificationRepository extends JpaRepository<Notification, Long>, | ||
NotificationRepositoryCustom, | ||
NotificationJdbcRepository { | ||
|
||
List<Notification> findAllByReceiverIdOrderByCreatedAtDesc(Long receiverId); | ||
} | ||
|
2 changes: 1 addition & 1 deletion
2
.../notice/NotificationRepositoryCustom.java → ...ication/NotificationRepositoryCustom.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
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
44 changes: 44 additions & 0 deletions
44
src/main/java/life/offonoff/ab/web/common/aspect/LoggingAspectHandler.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,44 @@ | ||
package life.offonoff.ab.web.common.aspect; | ||
|
||
import org.aspectj.lang.JoinPoint; | ||
import org.aspectj.lang.ProceedingJoinPoint; | ||
import org.aspectj.lang.annotation.*; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.context.request.RequestContextHolder; | ||
import org.springframework.web.context.request.ServletRequestAttributes; | ||
|
||
import java.util.Optional; | ||
|
||
@Component | ||
@Aspect | ||
public class LoggingAspectHandler { | ||
private final Logger log = LoggerFactory.getLogger(this.getClass().getSimpleName()); | ||
@Pointcut("execution(* life.offonoff.ab.web.*.*(..))") | ||
private void allControllers() { | ||
} | ||
|
||
@Around("allControllers()") | ||
public Object doReturnLogging(ProceedingJoinPoint joinPoint) throws Throwable { | ||
String methodName = joinPoint.getSignature().toShortString(); | ||
Object[] arguments = joinPoint.getArgs(); | ||
|
||
log.info("[BEFORE] METHOD={} PARAMETER={} WILL EXECUTE", methodName, arguments); | ||
|
||
Object returnedByMethod = joinPoint.proceed(arguments); | ||
|
||
log.info("[RETURNED] METHOD={} PARAMETER={} RETURNED={}", joinPoint.getSignature().toShortString(), joinPoint.getArgs(), returnedByMethod); | ||
|
||
return returnedByMethod; | ||
} | ||
|
||
@AfterThrowing(value = "allControllers()", throwing = "exception") | ||
public void doExceptionLogging(JoinPoint joinPoint, Exception exception) { | ||
String ip = Optional.ofNullable((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) | ||
.map(attributes -> attributes.getRequest().getHeader("X-Real-IP")) | ||
.orElse(""); | ||
log.error("[EXCEPTION THROWN] METHOD={} PARAMETER={} THREW EXCEPTION={} | ip={}", | ||
joinPoint.getSignature().toShortString(), joinPoint.getArgs(), exception, ip); | ||
} | ||
} |
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
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
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
2 changes: 1 addition & 1 deletion
2
...ry/notice/NotificationRepositoryTest.java → ...tfication/NotificationRepositoryTest.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
Oops, something went wrong.