-
Notifications
You must be signed in to change notification settings - Fork 0
version 2.17.1 #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
version 2.17.1 #349
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
src/main/java/com/kustacks/kuring/club/adapter/out/persistence/ClubPersistenceAdapter.java
This file contains hidden or 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,61 @@ | ||
| package com.kustacks.kuring.club.adapter.out.persistence; | ||
|
|
||
| import com.kustacks.kuring.club.application.port.out.ClubQueryPort; | ||
| import com.kustacks.kuring.club.application.port.out.ClubSubscriptionCommandPort; | ||
| import com.kustacks.kuring.club.application.port.out.ClubSubscriptionQueryPort; | ||
| import com.kustacks.kuring.club.domain.Club; | ||
| import com.kustacks.kuring.club.domain.ClubSubscribe; | ||
| import com.kustacks.kuring.common.annotation.PersistenceAdapter; | ||
| import com.kustacks.kuring.user.domain.RootUser; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| @PersistenceAdapter | ||
| @RequiredArgsConstructor | ||
| public class ClubPersistenceAdapter implements ClubQueryPort, ClubSubscriptionCommandPort, ClubSubscriptionQueryPort { | ||
|
|
||
| private final ClubRepository clubRepository; | ||
| private final ClubSubscribeRepository clubSubscribeRepository; | ||
|
|
||
| @Override | ||
| public Optional<Club> findClubById(Long id) { | ||
| return clubRepository.findById(id); | ||
| } | ||
|
|
||
| @Override | ||
| public List<Club> findClubsBetweenDates(LocalDateTime start, LocalDateTime end) { | ||
| return clubRepository.findClubsBetweenDates(start, end); | ||
| } | ||
|
|
||
| @Override | ||
| public List<Club> findNextDayRecruitEndClubs(LocalDateTime now) { | ||
| LocalDate tomorrow = now.toLocalDate().plusDays(1); | ||
| LocalDateTime startInclusive = tomorrow.atStartOfDay(); | ||
| LocalDateTime endExclusive = tomorrow.plusDays(1).atStartOfDay(); | ||
| return findClubsBetweenDates(startInclusive, endExclusive); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean existsSubscription(Long rootUserId, Long clubId) { | ||
| return clubSubscribeRepository.existsByRootUserIdAndClubId(rootUserId, clubId); | ||
| } | ||
|
|
||
| @Override | ||
| public void saveSubscription(RootUser rootUser, Club club) { | ||
| clubSubscribeRepository.save(new ClubSubscribe(rootUser, club)); | ||
| } | ||
|
|
||
| @Override | ||
| public void deleteSubscription(RootUser rootUser, Club club) { | ||
| clubSubscribeRepository.deleteByRootUserAndClub(rootUser, club); | ||
| } | ||
|
|
||
| @Override | ||
| public long countSubscriptions(Long rootUserId) { | ||
| return clubSubscribeRepository.countByRootUserId(rootUserId); | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/kustacks/kuring/club/adapter/out/persistence/ClubQueryRepository.java
This file contains hidden or 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,11 @@ | ||
| package com.kustacks.kuring.club.adapter.out.persistence; | ||
|
|
||
| import com.kustacks.kuring.club.domain.Club; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
|
|
||
| public interface ClubQueryRepository { | ||
|
|
||
| List<Club> findClubsBetweenDates(LocalDateTime start, LocalDateTime end); | ||
| } |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/kustacks/kuring/club/adapter/out/persistence/ClubQueryRepositoryImpl.java
This file contains hidden or 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,36 @@ | ||
| package com.kustacks.kuring.club.adapter.out.persistence; | ||
|
|
||
| import com.kustacks.kuring.club.domain.Club; | ||
| import com.querydsl.core.types.dsl.BooleanExpression; | ||
| import com.querydsl.jpa.impl.JPAQueryFactory; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
|
|
||
| import static com.kustacks.kuring.club.domain.QClub.club; | ||
|
|
||
| @RequiredArgsConstructor | ||
| class ClubQueryRepositoryImpl implements ClubQueryRepository { | ||
|
|
||
| private final JPAQueryFactory queryFactory; | ||
|
|
||
| @Override | ||
| public List<Club> findClubsBetweenDates(LocalDateTime start, LocalDateTime end) { | ||
| return queryFactory.selectFrom(club) | ||
| .where( | ||
| club.isAlways.isFalse(), | ||
| recruitEndAtGoe(start), | ||
| recruitEndAtLt(end) | ||
| ) | ||
| .fetch(); | ||
| } | ||
|
|
||
| private BooleanExpression recruitEndAtGoe(LocalDateTime start) { | ||
| return start != null ? club.recruitEndAt.goe(start) : null; | ||
| } | ||
|
|
||
| private BooleanExpression recruitEndAtLt(LocalDateTime end) { | ||
| return end != null ? club.recruitEndAt.lt(end) : null; | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/kustacks/kuring/club/adapter/out/persistence/ClubRepository.java
This file contains hidden or 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,7 @@ | ||
| package com.kustacks.kuring.club.adapter.out.persistence; | ||
|
|
||
| import com.kustacks.kuring.club.domain.Club; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| interface ClubRepository extends JpaRepository<Club, Long>, ClubQueryRepository { | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/kustacks/kuring/club/adapter/out/persistence/ClubSubscribeRepository.java
This file contains hidden or 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 com.kustacks.kuring.club.adapter.out.persistence; | ||
|
|
||
| import com.kustacks.kuring.club.domain.Club; | ||
| import com.kustacks.kuring.club.domain.ClubSubscribe; | ||
| import com.kustacks.kuring.user.domain.RootUser; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| interface ClubSubscribeRepository extends JpaRepository<ClubSubscribe, Long> { | ||
|
|
||
| boolean existsByRootUserIdAndClubId(Long rootUserId, Long clubId); | ||
|
|
||
| long countByRootUserId(Long rootUserId); | ||
|
|
||
| void deleteByRootUserAndClub(RootUser rootUser, Club club); | ||
| } |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/kustacks/kuring/club/application/port/in/ClubNotificationUseCase.java
This file contains hidden or 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,6 @@ | ||
| package com.kustacks.kuring.club.application.port.in; | ||
|
|
||
| public interface ClubNotificationUseCase { | ||
|
|
||
| void sendDeadlineNotifications(); | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/kustacks/kuring/club/application/port/in/ClubSubscriptionUseCase.java
This file contains hidden or 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,10 @@ | ||
| package com.kustacks.kuring.club.application.port.in; | ||
|
|
||
| import com.kustacks.kuring.club.application.port.in.dto.ClubSubscriptionCommand; | ||
|
|
||
| public interface ClubSubscriptionUseCase { | ||
|
|
||
| long addSubscription(ClubSubscriptionCommand command); | ||
|
|
||
| long removeSubscription(ClubSubscriptionCommand command); | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/kustacks/kuring/club/application/port/in/dto/ClubSubscriptionCommand.java
This file contains hidden or 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,7 @@ | ||
| package com.kustacks.kuring.club.application.port.in.dto; | ||
|
|
||
| public record ClubSubscriptionCommand( | ||
| String email, | ||
| Long clubId | ||
| ) { | ||
| } |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/kustacks/kuring/club/application/port/out/ClubQueryPort.java
This file contains hidden or 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,16 @@ | ||
| package com.kustacks.kuring.club.application.port.out; | ||
|
|
||
| import com.kustacks.kuring.club.domain.Club; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| public interface ClubQueryPort { | ||
|
|
||
| Optional<Club> findClubById(Long id); | ||
|
|
||
| List<Club> findClubsBetweenDates(LocalDateTime start, LocalDateTime end); | ||
|
|
||
| List<Club> findNextDayRecruitEndClubs(LocalDateTime now); | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/kustacks/kuring/club/application/port/out/ClubSubscriptionCommandPort.java
This file contains hidden or 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,11 @@ | ||
| package com.kustacks.kuring.club.application.port.out; | ||
|
|
||
| import com.kustacks.kuring.club.domain.Club; | ||
| import com.kustacks.kuring.user.domain.RootUser; | ||
|
|
||
| public interface ClubSubscriptionCommandPort { | ||
|
|
||
| void saveSubscription(RootUser rootUser, Club club); | ||
|
|
||
| void deleteSubscription(RootUser rootUser, Club club); | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/kustacks/kuring/club/application/port/out/ClubSubscriptionQueryPort.java
This file contains hidden or 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,8 @@ | ||
| package com.kustacks.kuring.club.application.port.out; | ||
|
|
||
| public interface ClubSubscriptionQueryPort { | ||
|
|
||
| boolean existsSubscription(Long rootUserId, Long clubId); | ||
|
|
||
| long countSubscriptions(Long rootUserId); | ||
| } |
97 changes: 97 additions & 0 deletions
97
src/main/java/com/kustacks/kuring/club/application/service/ClubCommandService.java
This file contains hidden or 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,97 @@ | ||
| package com.kustacks.kuring.club.application.service; | ||
|
|
||
| import com.kustacks.kuring.club.application.port.in.ClubSubscriptionUseCase; | ||
| import com.kustacks.kuring.club.application.port.in.dto.ClubSubscriptionCommand; | ||
| import com.kustacks.kuring.club.application.port.out.ClubQueryPort; | ||
| import com.kustacks.kuring.club.application.port.out.ClubSubscriptionCommandPort; | ||
| import com.kustacks.kuring.club.application.port.out.ClubSubscriptionQueryPort; | ||
| import com.kustacks.kuring.club.domain.Club; | ||
| import com.kustacks.kuring.common.annotation.UseCase; | ||
| import com.kustacks.kuring.common.exception.InvalidStateException; | ||
| import com.kustacks.kuring.common.exception.code.ErrorCode; | ||
| import com.kustacks.kuring.common.properties.ServerProperties; | ||
| import com.kustacks.kuring.user.application.port.out.RootUserQueryPort; | ||
| import com.kustacks.kuring.user.application.port.out.UserEventPort; | ||
| import com.kustacks.kuring.user.application.port.out.UserQueryPort; | ||
| import com.kustacks.kuring.user.domain.RootUser; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Slf4j | ||
| @UseCase | ||
| @Transactional | ||
| @RequiredArgsConstructor | ||
| public class ClubCommandService implements ClubSubscriptionUseCase { | ||
|
|
||
| private static final String CLUB_TOPIC_PREFIX = "club."; | ||
|
|
||
| private final ServerProperties serverProperties; | ||
| private final ClubQueryPort clubQueryPort; | ||
| private final ClubSubscriptionCommandPort clubSubscriptionCommandPort; | ||
| private final ClubSubscriptionQueryPort countSubscriptionsQueryPort; | ||
| private final RootUserQueryPort rootUserQueryPort; | ||
| private final UserQueryPort userQueryPort; | ||
| private final UserEventPort userEventPort; | ||
|
|
||
| @Override | ||
| public long addSubscription(ClubSubscriptionCommand command) { | ||
| RootUser rootUser = findRootUserByEmail(command.email()); | ||
| Club club = findClubById(command.clubId()); | ||
|
|
||
| if (isAlreadySubscription(rootUser, club)) { | ||
| throw new InvalidStateException(ErrorCode.CLUB_ALREADY_SUBSCRIBED); | ||
| } | ||
|
|
||
| clubSubscriptionCommandPort.saveSubscription(rootUser, club); | ||
| subscribeAllLoggedInDevices(rootUser.getId(), makeTopic(club)); | ||
|
|
||
| return countSubscriptionsQueryPort.countSubscriptions(rootUser.getId()); | ||
|
Comment on lines
+46
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 외부 토픽 구독/해제를 트랜잭션 내부에서 호출하면 데이터-외부상태 불일치가 발생할 수 있습니다. DB 트랜잭션이 롤백되더라도 외부 구독 상태는 이미 변경될 수 있어 정합성이 깨질 수 있습니다. 외부 호출은 커밋 이후로 분리하는 게 안전합니다. 🔧 제안 수정안+import org.springframework.transaction.support.TransactionSynchronization;
+import org.springframework.transaction.support.TransactionSynchronizationManager;
@@
- clubSubscriptionCommandPort.saveSubscription(rootUser, club);
- subscribeAllLoggedInDevices(rootUser.getId(), makeTopic(club));
+ clubSubscriptionCommandPort.saveSubscription(rootUser, club);
+ runAfterCommit(() -> subscribeAllLoggedInDevices(rootUser.getId(), makeTopic(club)));
@@
- clubSubscriptionCommandPort.deleteSubscription(rootUser, club);
- unsubscribeAllLoggedInDevices(rootUser.getId(), makeTopic(club));
+ clubSubscriptionCommandPort.deleteSubscription(rootUser, club);
+ runAfterCommit(() -> unsubscribeAllLoggedInDevices(rootUser.getId(), makeTopic(club)));
@@
+ private void runAfterCommit(Runnable action) {
+ if (!TransactionSynchronizationManager.isActualTransactionActive()) {
+ action.run();
+ return;
+ }
+ TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
+ `@Override`
+ public void afterCommit() {
+ action.run();
+ }
+ });
+ }Also applies to: 60-63, 80-92 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| @Override | ||
| public long removeSubscription(ClubSubscriptionCommand command) { | ||
| RootUser rootUser = findRootUserByEmail(command.email()); | ||
| Club club = findClubById(command.clubId()); | ||
|
|
||
| if (!isAlreadySubscription(rootUser, club)) { | ||
| throw new InvalidStateException(ErrorCode.CLUB_NOT_SUBSCRIBED); | ||
| } | ||
| clubSubscriptionCommandPort.deleteSubscription(rootUser, club); | ||
| unsubscribeAllLoggedInDevices(rootUser.getId(), makeTopic(club)); | ||
|
|
||
| return countSubscriptionsQueryPort.countSubscriptions(rootUser.getId()); | ||
| } | ||
|
|
||
| private boolean isAlreadySubscription(RootUser rootUser, Club club) { | ||
| return countSubscriptionsQueryPort.existsSubscription(rootUser.getId(), club.getId()); | ||
| } | ||
|
|
||
| private RootUser findRootUserByEmail(String email) { | ||
| return rootUserQueryPort.findRootUserByEmail(email) | ||
| .orElseThrow(() -> new InvalidStateException(ErrorCode.ROOT_USER_NOT_FOUND)); | ||
| } | ||
|
|
||
| private Club findClubById(Long id) { | ||
| return clubQueryPort.findClubById(id) | ||
| .orElseThrow(() -> new InvalidStateException(ErrorCode.CLUB_NOT_FOUND)); | ||
| } | ||
|
|
||
| private void subscribeAllLoggedInDevices(Long rootUserId, String topic) { | ||
| userQueryPort.findByLoggedInUserId(rootUserId) | ||
| .forEach(user -> userEventPort.subscribeEvent(user.getFcmToken(), topic)); | ||
|
|
||
| log.info("동아리 토픽 구독 완료. rootUserId={}, topic={}", rootUserId, topic); | ||
| } | ||
|
|
||
| private void unsubscribeAllLoggedInDevices(Long rootUserId, String topic) { | ||
| userQueryPort.findByLoggedInUserId(rootUserId) | ||
| .forEach(user -> userEventPort.unsubscribeEvent(user.getFcmToken(), topic)); | ||
|
|
||
| log.info("동아리 토픽 구독 해제 완료. rootUserId={}, topic={}", rootUserId, topic); | ||
| } | ||
|
|
||
| private String makeTopic(Club club) { | ||
| return serverProperties.ifDevThenAddSuffix(CLUB_TOPIC_PREFIX + club.getId()); | ||
| } | ||
| } | ||
82 changes: 82 additions & 0 deletions
82
src/main/java/com/kustacks/kuring/club/application/service/ClubNotificationService.java
This file contains hidden or 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,82 @@ | ||
| package com.kustacks.kuring.club.application.service; | ||
|
|
||
| import com.google.firebase.messaging.Message; | ||
| import com.google.firebase.messaging.Notification; | ||
| import com.kustacks.kuring.club.application.port.in.ClubNotificationUseCase; | ||
| import com.kustacks.kuring.club.application.port.out.ClubQueryPort; | ||
| import com.kustacks.kuring.club.domain.Club; | ||
| import com.kustacks.kuring.common.annotation.UseCase; | ||
| import com.kustacks.kuring.common.properties.ServerProperties; | ||
| import com.kustacks.kuring.message.application.port.out.FirebaseMessagingPort; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import static com.kustacks.kuring.message.domain.MessageType.CLUB; | ||
|
|
||
| @Slf4j | ||
| @UseCase | ||
| @RequiredArgsConstructor | ||
| public class ClubNotificationService implements ClubNotificationUseCase { | ||
|
|
||
| private static final String CLUB_TOPIC_PREFIX = "club."; | ||
| private static final String D_DAY_1_TITLE = "[D-1] %s 동아리 모집"; | ||
| private static final String D_DAY_1_BODY = "내일 마감되기 전에 지원하세요!"; | ||
|
|
||
| private final ClubQueryPort clubQueryPort; | ||
| private final FirebaseMessagingPort firebaseMessagingPort; | ||
| private final ServerProperties serverProperties; | ||
|
|
||
| @Override | ||
| public void sendDeadlineNotifications() { | ||
| List<Club> clubs = findDeadlineClubs(); | ||
| clubs.forEach(this::sendDeadLineClubNotification); | ||
| } | ||
|
|
||
| private void sendDeadLineClubNotification(Club club) { | ||
| try { | ||
| Message message = buildMessage(club); | ||
| firebaseMessagingPort.send(message); | ||
| log.info("동아리 마감 알림 발송 완료. clubId={}", club.getId()); | ||
| } catch (Exception e) { | ||
| log.error("동아리 마감 알림 발송 실패. clubId={}", club.getId(), e); | ||
| } | ||
| } | ||
|
|
||
| private List<Club> findDeadlineClubs() { | ||
| return clubQueryPort.findNextDayRecruitEndClubs(LocalDateTime.now()); | ||
| } | ||
|
|
||
| private Message buildMessage(Club club) { | ||
| String messageTitle = String.format(D_DAY_1_TITLE, club.getName()); | ||
|
|
||
| return Message.builder() | ||
| .setNotification(buildNotification(messageTitle, D_DAY_1_BODY)) | ||
| .setTopic(buildTopic(club)) | ||
| .putAllData(buildMessageData(messageTitle, D_DAY_1_BODY, club)) | ||
| .build(); | ||
| } | ||
|
|
||
| private Map<String, String> buildMessageData(String title, String body, Club club) { | ||
| return Map.of( | ||
| "clubId", String.valueOf(club.getId()), | ||
| "title", title, | ||
| "body", body, | ||
| "messageType", CLUB.getValue() | ||
| ); | ||
| } | ||
|
|
||
| private String buildTopic(Club club) { | ||
| return serverProperties.ifDevThenAddSuffix(CLUB_TOPIC_PREFIX + club.getId()); | ||
| } | ||
|
|
||
| private Notification buildNotification(String title, String body) { | ||
| return Notification.builder() | ||
| .setTitle(title) | ||
| .setBody(body) | ||
| .build(); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
구독 상태 체크 후 저장/삭제하는 패턴이 동시성 경쟁 상태를 만듭니다.
exists와save/delete가 원자적으로 보장되지 않아 동시 요청에서 중복 저장 또는 의도와 다른 성공/실패 결과가 발생할 수 있습니다. 저장/삭제는 DB 제약 기반으로 처리하고 충돌 예외를 도메인 예외로 매핑하는 방식이 필요합니다.Also applies to: 57-61
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분은 낙관적으로 처리하는거에 대한 고민을 해봐야겠네
이 부분을 요약해서 이슈로 만들어줘
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
@rlagkswn00, 동시성 이슈를 정리해서 GitHub 이슈로 생성하겠습니다.🏁 Script executed:
Length of output: 57
@rlagkswn00, 동시성 경쟁 상태 이슈를 생성했습니다!이슈
#351: 동아리 구독 기능의 동시성 경쟁 상태 개선낙관적 처리 방식을 포함한 다양한 동시성 제어 방안을 검토하실 때 참고하시면 됩니다.