From 1ddd5ccd2c2e8929b6fc642e34ba32e897324343 Mon Sep 17 00:00:00 2001 From: jun02160 Date: Fri, 25 Aug 2023 00:27:07 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT]=20=EB=AA=A8=EB=93=A0=20=EC=A7=88?= =?UTF-8?q?=EB=8B=B5=20=EC=99=84=EB=A3=8C=20=EC=8B=9C=20=EC=9D=91=EB=8B=B5?= =?UTF-8?q?=EA=B0=92=20=EA=B5=AC=EB=B6=84=20#100?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/umbba/api/service/qna/QnAService.java | 6 ++++++ .../parentchild/dao/ParentchildDao.java | 8 +++++++- .../config/ConnectionClosingAspect.java | 19 +++++++++++++++++++ .../notification/service/fcm/FCMService.java | 3 ++- .../service/scheduler/FCMScheduler.java | 7 +++++-- .../src/main/resources/application.yaml | 2 +- 6 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 umbba-notification/src/main/java/sopt/org/umbba/notification/config/ConnectionClosingAspect.java diff --git a/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java b/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java index 434dc8f5..514448ed 100644 --- a/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java +++ b/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java @@ -305,6 +305,12 @@ public GetMainViewResponseDto getMainInfo(Long userId) { QnA lastQna = qnaList.get(parentchild.getCount()-1); log.info("getCount(): {}", parentchild.getCount()); + QnA currentQnA = parentchild.getQnaList().get(parentchild.getCount() - 1); + if (parentchild.getCount() == 7 && (currentQnA.isParentAnswer() && currentQnA.isChildAnswer())) { + return GetMainViewResponseDto.of(lastQna, parentchild.getCount()+1); // 유효하지 않은 8로 반환 시 엔딩이벤트 + } + + return GetMainViewResponseDto.of(lastQna, parentchild.getCount()); } diff --git a/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/parentchild/dao/ParentchildDao.java b/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/parentchild/dao/ParentchildDao.java index 40627f80..0eae00df 100644 --- a/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/parentchild/dao/ParentchildDao.java +++ b/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/parentchild/dao/ParentchildDao.java @@ -14,11 +14,17 @@ @Slf4j @Repository -public class ParentchildDao { +public class ParentchildDao implements AutoCloseable { @PersistenceContext private EntityManager em; + + @Override + public void close() throws Exception { + + } + public Optional findByUserId(Long userId) { String jpql = "SELECT pc FROM Parentchild pc " + diff --git a/umbba-notification/src/main/java/sopt/org/umbba/notification/config/ConnectionClosingAspect.java b/umbba-notification/src/main/java/sopt/org/umbba/notification/config/ConnectionClosingAspect.java new file mode 100644 index 00000000..9b4a5fd4 --- /dev/null +++ b/umbba-notification/src/main/java/sopt/org/umbba/notification/config/ConnectionClosingAspect.java @@ -0,0 +1,19 @@ +/* +package sopt.org.umbba.notification.config; + +import org.aspectj.lang.annotation.AfterThrowing; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; + +import java.sql.Connection; + +@Aspect +@Component +public class ConnectionClosingAspect { + + @AfterThrowing(pointcut = "execution(* sopt.org.umbba.notification.service.*.*(..))", throwing = "ex") + public void closeConnectionOnException(Exception ex) { + Connection conn = + } +} +*/ diff --git a/umbba-notification/src/main/java/sopt/org/umbba/notification/service/fcm/FCMService.java b/umbba-notification/src/main/java/sopt/org/umbba/notification/service/fcm/FCMService.java index f031721c..76b1c521 100644 --- a/umbba-notification/src/main/java/sopt/org/umbba/notification/service/fcm/FCMService.java +++ b/umbba-notification/src/main/java/sopt/org/umbba/notification/service/fcm/FCMService.java @@ -186,7 +186,8 @@ public void schedulePushAlarm(String cronExpression, Long parentchildId) { try { Thread.sleep(1000); } catch (InterruptedException e) { - throw new RuntimeException(e); + Thread.currentThread().interrupt(); +// throw new RuntimeException(e); } TransactionDefinition transactionDefinition = new DefaultTransactionDefinition(); diff --git a/umbba-notification/src/main/java/sopt/org/umbba/notification/service/scheduler/FCMScheduler.java b/umbba-notification/src/main/java/sopt/org/umbba/notification/service/scheduler/FCMScheduler.java index a618ef3a..f99bacf2 100644 --- a/umbba-notification/src/main/java/sopt/org/umbba/notification/service/scheduler/FCMScheduler.java +++ b/umbba-notification/src/main/java/sopt/org/umbba/notification/service/scheduler/FCMScheduler.java @@ -2,6 +2,8 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.annotation.AfterThrowing; +import org.aspectj.lang.annotation.Aspect; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -15,6 +17,7 @@ import java.util.List; @Slf4j +@Aspect @Component @RequiredArgsConstructor public class FCMScheduler { @@ -42,8 +45,8 @@ public String pushTodayQna() { }) .forEach(pc -> { log.info(pc.getId() + "번째 Parentchild"); - String cronExpression = String.format("0 %s %s * * ?", pc.getPushTime().getMinute(), pc.getPushTime().getHour()); -// String cronExpression = String.format("*/20 * * * * *"); +// String cronExpression = String.format("0 %s %s * * ?", pc.getPushTime().getMinute(), pc.getPushTime().getHour()); + String cronExpression = String.format("*/20 * * * * *"); log.info("cron: {}", cronExpression); fcmService.schedulePushAlarm(cronExpression, pc.getId()); }); diff --git a/umbba-notification/src/main/resources/application.yaml b/umbba-notification/src/main/resources/application.yaml index 93c96e4d..6c1d8283 100644 --- a/umbba-notification/src/main/resources/application.yaml +++ b/umbba-notification/src/main/resources/application.yaml @@ -29,7 +29,7 @@ spring: connection-timeout: 30000 # 30초(default: 30초) maximum-pool-size: 10 # default: 10개 max-lifetime: 600000 # 10분(default: 30분) - leak-detection-threshold: 2000 # default: 0(이용X) + leak-detection-threshold: 60000 # default: 0(이용X) jpa: show-sql: false hibernate: