-
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.
[OING-173] feat: MVP 2차 추억 캘린더 배너 구현 (#132)
* feat: Add familyScore definition * feat: Add JpaEntity and SpringEvent to add score per user activity * feat: Add the events to substract score per canceled user activity * fix: Change FamilyScoreEventListener annotation to fix not committed score event * feat: Impl the code to calculate the familyTopPercentage in getBanner API * feat: Impl the code to count family activity in getBanner API * feat: Add counting code to banners dynamic fields(allFamilyMembersUploadedDays, allFamilyMembersUploadedStreaks) and Impl getBanner API with a lot of comments * fix: Fix broken test code with changed Member entity * fix: Handle divide by zero error from calculateFamilyTopPercentile method * fix: Replace inclusiveToday as endDate from the code to calculate dynamic field of getBanner API to fix wrongly selected period * chore: Clear the commenting at redis cache annotation in MemberPostController
- Loading branch information
Showing
39 changed files
with
609 additions
and
50 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -38,6 +38,7 @@ out/ | |
|
||
application-local.yaml | ||
.env | ||
data.sql | ||
|
||
### QueryDSL ### | ||
generated/ |
15 changes: 15 additions & 0 deletions
15
common/src/main/java/com/oing/event/MemberPostCommentCreatedEvent.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 com.oing.event; | ||
|
||
import lombok.Getter; | ||
import org.springframework.context.ApplicationEvent; | ||
|
||
@Getter | ||
public class MemberPostCommentCreatedEvent extends ApplicationEvent { | ||
|
||
private final String memberId; | ||
|
||
public MemberPostCommentCreatedEvent(Object source, String memberId) { | ||
super(source); | ||
this.memberId = memberId; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
common/src/main/java/com/oing/event/MemberPostCommentDeletedEvent.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 com.oing.event; | ||
|
||
import lombok.Getter; | ||
import org.springframework.context.ApplicationEvent; | ||
|
||
@Getter | ||
public class MemberPostCommentDeletedEvent extends ApplicationEvent { | ||
|
||
private final String memberId; | ||
|
||
public MemberPostCommentDeletedEvent(Object source, String memberId) { | ||
super(source); | ||
this.memberId = memberId; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
common/src/main/java/com/oing/event/MemberPostCreatedEvent.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 com.oing.event; | ||
|
||
import lombok.Getter; | ||
import org.springframework.context.ApplicationEvent; | ||
|
||
@Getter | ||
public class MemberPostCreatedEvent extends ApplicationEvent { | ||
|
||
private final String memberId; | ||
|
||
public MemberPostCreatedEvent(Object source, String memberId) { | ||
super(source); | ||
this.memberId = memberId; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
common/src/main/java/com/oing/event/MemberPostDeletedEvent.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 com.oing.event; | ||
|
||
import lombok.Getter; | ||
import org.springframework.context.ApplicationEvent; | ||
|
||
@Getter | ||
public class MemberPostDeletedEvent extends ApplicationEvent { | ||
|
||
private final String memberId; | ||
|
||
public MemberPostDeletedEvent(Object source, String memberId) { | ||
super(source); | ||
this.memberId = memberId; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
common/src/main/java/com/oing/event/MemberPostReactionCreatedEvent.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 com.oing.event; | ||
|
||
import lombok.Getter; | ||
import org.springframework.context.ApplicationEvent; | ||
|
||
@Getter | ||
public class MemberPostReactionCreatedEvent extends ApplicationEvent { | ||
|
||
private final String memberId; | ||
|
||
public MemberPostReactionCreatedEvent(Object source, String memberId) { | ||
super(source); | ||
this.memberId = memberId; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
common/src/main/java/com/oing/event/MemberPostReactionDeletedEvent.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 com.oing.event; | ||
|
||
import lombok.Getter; | ||
import org.springframework.context.ApplicationEvent; | ||
|
||
@Getter | ||
public class MemberPostReactionDeletedEvent extends ApplicationEvent { | ||
|
||
private final String memberId; | ||
|
||
public MemberPostReactionDeletedEvent(Object source, String memberId) { | ||
super(source); | ||
this.memberId = memberId; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
common/src/main/java/com/oing/event/MemberPostRealEmojiCreatedEvent.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 com.oing.event; | ||
|
||
import lombok.Getter; | ||
import org.springframework.context.ApplicationEvent; | ||
|
||
@Getter | ||
public class MemberPostRealEmojiCreatedEvent extends ApplicationEvent { | ||
|
||
private final String memberId; | ||
|
||
public MemberPostRealEmojiCreatedEvent(Object source, String memberId) { | ||
super(source); | ||
this.memberId = memberId; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
common/src/main/java/com/oing/event/MemberPostRealEmojiDeletedEvent.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 com.oing.event; | ||
|
||
import lombok.Getter; | ||
import org.springframework.context.ApplicationEvent; | ||
|
||
@Getter | ||
public class MemberPostRealEmojiDeletedEvent extends ApplicationEvent { | ||
|
||
private final String memberId; | ||
|
||
public MemberPostRealEmojiDeletedEvent(Object source, String memberId) { | ||
super(source); | ||
this.memberId = memberId; | ||
} | ||
} |
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
79 changes: 79 additions & 0 deletions
79
family/src/main/java/com/oing/event/FamilyScoreEventListener.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,79 @@ | ||
package com.oing.event; | ||
|
||
import com.oing.service.FamilyService; | ||
import com.oing.service.MemberBridge; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Propagation; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.transaction.event.TransactionPhase; | ||
import org.springframework.transaction.event.TransactionalEventListener; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class FamilyScoreEventListener { | ||
|
||
public final MemberBridge memberBridge; | ||
public final FamilyService familyService; | ||
|
||
// TODO: 1. BEFORE_COMMIT, 2. Async 모두 작동 안함. 원인 파악 후 리펙토링 필요. | ||
// @TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) | ||
// @Async | ||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
@Transactional(propagation = Propagation.REQUIRES_NEW) | ||
public void onMemberPostCreatedEvent(MemberPostCreatedEvent memberPostCreatedEvent) { | ||
String familyId = memberBridge.getFamilyIdByMemberId(memberPostCreatedEvent.getMemberId()); | ||
familyService.getFamilyById(familyId).addNewPostScore(); | ||
} | ||
|
||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
@Transactional(propagation = Propagation.REQUIRES_NEW) | ||
public void onMemberPostDeletedEvent(MemberPostDeletedEvent memberPostDeletedEvent) { | ||
String familyId = memberBridge.getFamilyIdByMemberId(memberPostDeletedEvent.getMemberId()); | ||
familyService.getFamilyById(familyId).subtractNewPostScore(); | ||
} | ||
|
||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
@Transactional(propagation = Propagation.REQUIRES_NEW) | ||
public void onMemberPostCommentCreatedEvent(MemberPostCommentCreatedEvent memberPostCommentCreatedEvent) { | ||
String familyId = memberBridge.getFamilyIdByMemberId(memberPostCommentCreatedEvent.getMemberId()); | ||
familyService.getFamilyById(familyId).addNewCommentScore(); | ||
} | ||
|
||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
@Transactional(propagation = Propagation.REQUIRES_NEW) | ||
public void onMemberPostCommentDeletedEvent(MemberPostCommentDeletedEvent memberPostCommentDeletedEvent) { | ||
String familyId = memberBridge.getFamilyIdByMemberId(memberPostCommentDeletedEvent.getMemberId()); | ||
familyService.getFamilyById(familyId).subtractNewCommentScore(); | ||
} | ||
|
||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
@Transactional(propagation = Propagation.REQUIRES_NEW) | ||
public void onMemberPostReactionCreatedEvent(MemberPostReactionCreatedEvent memberPostReactionCreatedEvent) { | ||
String familyId = memberBridge.getFamilyIdByMemberId(memberPostReactionCreatedEvent.getMemberId()); | ||
familyService.getFamilyById(familyId).addNewReactionScore(); | ||
} | ||
|
||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
@Transactional(propagation = Propagation.REQUIRES_NEW) | ||
public void onMemberPostReactionDeletedEvent(MemberPostReactionDeletedEvent memberPostReactionDeletedEvent) { | ||
String familyId = memberBridge.getFamilyIdByMemberId(memberPostReactionDeletedEvent.getMemberId()); | ||
familyService.getFamilyById(familyId).subtractNewReactionScore(); | ||
} | ||
|
||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
@Transactional(propagation = Propagation.REQUIRES_NEW) | ||
public void onMemberPostRealEmojiCreatedEvent(MemberPostRealEmojiCreatedEvent memberPostRealEmojiCreatedEvent) { | ||
String familyId = memberBridge.getFamilyIdByMemberId(memberPostRealEmojiCreatedEvent.getMemberId()); | ||
familyService.getFamilyById(familyId).addNewRealEmojiScore(); | ||
} | ||
|
||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
@Transactional(propagation = Propagation.REQUIRES_NEW) | ||
public void onMemberPostRealEmojiDeletedEvent(MemberPostRealEmojiDeletedEvent memberPostRealEmojiDeletedEvent) { | ||
String familyId = memberBridge.getFamilyIdByMemberId(memberPostRealEmojiDeletedEvent.getMemberId()); | ||
familyService.getFamilyById(familyId).subtractNewRealEmojiScore(); | ||
} | ||
|
||
|
||
} |
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
Oops, something went wrong.