-
Notifications
You must be signed in to change notification settings - Fork 0
[FIX] 답변 / 댓글 isLiked 오류 수정 #284
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ffbdfd9
fix: #283 답변 좋아요 isLiked 에러 해결
kyxxgsoo a31e141
feat: #283 AnswerCommentHeart 엔티티 생성
kyxxgsoo 3836037
feat: #283 AnswerCommentHeart 관련 서비스/레포지토리 로직 구현
kyxxgsoo 62fad60
feat: #283 AnswerCommentHeart 좋아요 로직 구현 및 페이지네이션 구현
kyxxgsoo 1a685f4
feat: #283 AnswerCommentHeart 관련 테스트 로직 수정
kyxxgsoo 8fc8389
feat: #283 AnswerCommentHeart 관련 테스트 Config 수정
kyxxgsoo 452c681
feat: #283 AnswerCommentHeart ConcurrentTest 관련 설정 추가
kyxxgsoo a3e404a
fix: #283 SliceResponse를 도입함으로써 사용되지 않는 코드 삭제
kyxxgsoo 8f1b301
fix: #283 isMine JsonProperty 지정 해제
kyxxgsoo 64df0a7
fix: #283 캐싱 및 트랜잭션 상태에 따른 이벤트 리스너 로직 수정
kyxxgsoo 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
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
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
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
16 changes: 16 additions & 0 deletions
16
src/main/java/com/server/capple/domain/answerComment/dao/AnswerCommentRDBDao.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.server.capple.domain.answerComment.dao; | ||
|
|
||
| import com.server.capple.domain.answerComment.entity.AnswerComment; | ||
| import com.server.capple.domain.member.entity.Member; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| public class AnswerCommentRDBDao { | ||
| public interface AnswerCommentInfoInterface { | ||
| public AnswerComment getAnswerComment(); | ||
| public Member getWriter(); | ||
| public String getContent(); | ||
| public LocalDateTime getCreatedAt(); | ||
| public Boolean getIsLiked(); | ||
| } | ||
| } |
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
35 changes: 35 additions & 0 deletions
35
src/main/java/com/server/capple/domain/answerComment/entity/AnswerCommentHeart.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,35 @@ | ||
| package com.server.capple.domain.answerComment.entity; | ||
|
|
||
| import com.server.capple.domain.answer.entity.Answer; | ||
| import com.server.capple.domain.member.entity.Member; | ||
| import com.server.capple.global.common.BaseEntity; | ||
| import jakarta.persistence.*; | ||
| import lombok.*; | ||
| import org.hibernate.annotations.SQLRestriction; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @Entity | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @AllArgsConstructor | ||
| @SQLRestriction("deleted_at is null") | ||
| public class AnswerCommentHeart extends BaseEntity { | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "answerComment_id", nullable = false) | ||
| private AnswerComment answerComment; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "member_id", nullable = false) | ||
| private Member member; | ||
|
|
||
| private boolean isLiked; | ||
|
|
||
| public boolean toggleHeart() { | ||
| this.isLiked = !this.isLiked; | ||
| return isLiked; | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/server/capple/domain/answerComment/mapper/AnswerCommentHeartMapper.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,20 @@ | ||
| package com.server.capple.domain.answerComment.mapper; | ||
|
|
||
| import com.server.capple.domain.answer.entity.Answer; | ||
| import com.server.capple.domain.answer.entity.AnswerHeart; | ||
| import com.server.capple.domain.answerComment.dto.AnswerCommentResponse; | ||
| import com.server.capple.domain.answerComment.entity.AnswerComment; | ||
| import com.server.capple.domain.answerComment.entity.AnswerCommentHeart; | ||
| import com.server.capple.domain.member.entity.Member; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| public class AnswerCommentHeartMapper { | ||
| public AnswerCommentHeart toAnswerCommentHeart(AnswerComment answerComment, Member member) { | ||
| return AnswerCommentHeart.builder() | ||
| .answerComment(answerComment) | ||
| .member(member) | ||
| .isLiked(false) | ||
| .build(); | ||
| } | ||
| } |
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
15 changes: 15 additions & 0 deletions
15
.../java/com/server/capple/domain/answerComment/repository/AnswerCommentHeartRepository.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.server.capple.domain.answerComment.repository; | ||
|
|
||
| import com.server.capple.domain.answer.entity.Answer; | ||
| import com.server.capple.domain.answer.entity.AnswerHeart; | ||
| import com.server.capple.domain.answerComment.entity.AnswerComment; | ||
| import com.server.capple.domain.answerComment.entity.AnswerCommentHeart; | ||
| import com.server.capple.domain.member.entity.Member; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public interface AnswerCommentHeartRepository extends JpaRepository<AnswerCommentHeart, Long> { | ||
|
|
||
| Optional<AnswerCommentHeart> findByMemberAndAnswerComment(Member member, AnswerComment answerComment); | ||
| } |
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
30 changes: 30 additions & 0 deletions
30
src/main/java/com/server/capple/domain/answerComment/service/AnswerCommentCountService.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,30 @@ | ||
| package com.server.capple.domain.answerComment.service; | ||
|
|
||
| import com.server.capple.domain.answer.repository.AnswerRepository; | ||
| import com.server.capple.domain.answerComment.repository.AnswerCommentRepository; | ||
| import com.server.capple.domain.member.entity.Member; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.cache.annotation.CacheEvict; | ||
| import org.springframework.cache.annotation.CachePut; | ||
| import org.springframework.cache.annotation.Cacheable; | ||
| import org.springframework.scheduling.annotation.Async; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.util.concurrent.CompletableFuture; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class AnswerCommentCountService { | ||
| private final AnswerCommentRepository answerCommentRepository; | ||
|
|
||
| @Cacheable(value = "answerComment", key = "#answerId", cacheManager = "oneDayExpireCacheManager") | ||
| public Integer getAnswerCommentCount(Long answerId) { | ||
| return answerCommentRepository.getAnswerCommentCountByAnswerId(answerId); | ||
| } | ||
|
|
||
| @Async | ||
| @CachePut(value = "answerComment", key = "#answerId", cacheManager = "oneDayExpireCacheManager") | ||
| public CompletableFuture<Integer> updateAnswerCommentCount(Long answerId) { | ||
| return CompletableFuture.completedFuture(answerCommentRepository.getAnswerCommentCountByAnswerId(answerId)); | ||
| } | ||
| } |
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
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.