-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 댓글방 생성 시점 변경 * refactor: 불필요한 도메인 OfferingWithRole 제거 * refactor: 불필요한 도메인 CommentWithRole 제거 * refactor: 댓글의 작성자 확인 메서드 추가 * refactor: 댓글방 목록 조회 dto 생성자 추가
- Loading branch information
1 parent
845115a
commit c6a71e9
Showing
10 changed files
with
52 additions
and
93 deletions.
There are no files selected for viewing
14 changes: 0 additions & 14 deletions
14
backend/src/main/java/com/zzang/chongdae/comment/domain/CommentWithRole.java
This file was deleted.
Oops, something went wrong.
13 changes: 1 addition & 12 deletions
13
backend/src/main/java/com/zzang/chongdae/comment/repository/CommentRepository.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,25 +1,14 @@ | ||
package com.zzang.chongdae.comment.repository; | ||
|
||
import com.zzang.chongdae.comment.domain.CommentWithRole; | ||
import com.zzang.chongdae.comment.repository.entity.CommentEntity; | ||
import com.zzang.chongdae.offering.repository.entity.OfferingEntity; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
public interface CommentRepository extends JpaRepository<CommentEntity, Long> { | ||
|
||
@Query(""" | ||
SELECT new com.zzang.chongdae.comment.domain.CommentWithRole(c, om.role) | ||
FROM CommentEntity as c JOIN OfferingMemberEntity as om | ||
ON c.offering = om.offering AND c.member = om.member | ||
WHERE om.offering = :offering | ||
ORDER BY c.createdAt | ||
""") | ||
List<CommentWithRole> findAllWithRoleByOffering(OfferingEntity offering); | ||
List<CommentEntity> findAllByOfferingOrderByCreatedAt(OfferingEntity offering); | ||
|
||
Optional<CommentEntity> findTopByOfferingOrderByCreatedAtDesc(OfferingEntity offering); | ||
|
||
Boolean existsByOffering(OfferingEntity offering); | ||
} |
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
16 changes: 14 additions & 2 deletions
16
backend/src/main/java/com/zzang/chongdae/comment/service/dto/CommentAllResponseItem.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,9 +1,21 @@ | ||
package com.zzang.chongdae.comment.service.dto; | ||
|
||
import com.zzang.chongdae.comment.repository.entity.CommentEntity; | ||
import com.zzang.chongdae.member.repository.entity.MemberEntity; | ||
|
||
public record CommentAllResponseItem(Long commentId, | ||
CommentCreatedAtResponse createdAt, | ||
String content, | ||
String nickname, | ||
Boolean isProposer, | ||
Boolean isMine) { | ||
boolean isProposer, | ||
boolean isMine) { | ||
|
||
public CommentAllResponseItem(CommentEntity comment, MemberEntity member) { | ||
this(comment.getId(), | ||
new CommentCreatedAtResponse(comment.getCreatedAt()), | ||
comment.getContent(), | ||
comment.getMember().getNickname(), | ||
comment.getOffering().isProposedBy(comment.getMember()), | ||
comment.isOwnedBy(member)); | ||
} | ||
} |
16 changes: 14 additions & 2 deletions
16
backend/src/main/java/com/zzang/chongdae/comment/service/dto/CommentRoomAllResponseItem.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,7 +1,19 @@ | ||
package com.zzang.chongdae.comment.service.dto; | ||
|
||
import com.zzang.chongdae.member.repository.entity.MemberEntity; | ||
import com.zzang.chongdae.offering.repository.entity.OfferingEntity; | ||
|
||
public record CommentRoomAllResponseItem(Long offeringId, | ||
String offeringTitle, | ||
CommentLatestResponse latestComment, | ||
Boolean isProposer) { | ||
Boolean isProposer, | ||
CommentLatestResponse latestComment) { | ||
|
||
public CommentRoomAllResponseItem(OfferingEntity offering, | ||
MemberEntity member, | ||
CommentLatestResponse latestComment) { | ||
this(offering.getId(), | ||
offering.getTitle(), | ||
offering.isProposedBy(member), | ||
latestComment); | ||
} | ||
} |
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
14 changes: 0 additions & 14 deletions
14
backend/src/main/java/com/zzang/chongdae/offering/domain/OfferingWithRole.java
This file was deleted.
Oops, something went wrong.
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