-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from tukcomCD2024/test#59/set-backend-test
- Loading branch information
Showing
35 changed files
with
721 additions
and
295 deletions.
There are no files selected for viewing
49 changes: 0 additions & 49 deletions
49
...end/memetory/src/main/java/com/example/memetory/domain/comment/controller/CommentApi.java
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
...etory/src/main/java/com/example/memetory/domain/comment/controller/CommentController.java
This file was deleted.
Oops, something went wrong.
69 changes: 34 additions & 35 deletions
69
backend/memetory/src/main/java/com/example/memetory/domain/comment/dto/CommentInfo.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,49 +1,48 @@ | ||
package com.example.memetory.domain.comment.dto; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import com.example.memetory.domain.comment.entity.Comment; | ||
import com.example.memetory.domain.member.dto.response.MemberResponse; | ||
import com.querydsl.core.annotations.QueryProjection; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@Schema(description = "댓글 정보") | ||
public class CommentInfo { | ||
|
||
@Schema(description = "댓글 아이디") | ||
private Long commentId; | ||
|
||
@Schema(description = "댓글 쓴 멤버 아이디") | ||
private Long memberId; | ||
|
||
@Schema(description = "댓글 쓴 멤버 이름") | ||
private String memberName; | ||
|
||
@Schema(description = "댓글 내용") | ||
private String content; | ||
|
||
@Schema(description = "댓글 생성 시각") | ||
private LocalDateTime createdAt; | ||
|
||
@Builder | ||
public CommentInfo(Long commentId, Long memberId, String memberName, String content, LocalDateTime createdAt) { | ||
this.commentId = commentId; | ||
this.memberId = memberId; | ||
this.memberName = memberName; | ||
this.content = content; | ||
this.createdAt = createdAt; | ||
} | ||
|
||
public static CommentInfo of(Comment comment) { | ||
return CommentInfo.builder() | ||
.commentId(comment.getId()) | ||
.memberId(comment.getMember().getId()) | ||
.memberName(comment.getMember().getName()) | ||
.content(comment.getContent()) | ||
.createdAt(comment.getCreatedAt()) | ||
.build(); | ||
} | ||
@Schema(description = "댓글 아이디") | ||
private Long commentId; | ||
|
||
@Schema(description = "댓글 쓴 멤버 정보") | ||
private MemberResponse member; | ||
|
||
@Schema(description = "댓글 내용") | ||
private String content; | ||
|
||
@Schema(description = "댓글 생성 시각") | ||
private LocalDateTime createdAt; | ||
|
||
@QueryProjection | ||
@Builder | ||
public CommentInfo(Long commentId, MemberResponse member, String content, LocalDateTime createdAt) { | ||
this.commentId = commentId; | ||
this.member = member; | ||
this.content = content; | ||
this.createdAt = createdAt; | ||
} | ||
|
||
public static CommentInfo of(Comment comment) { | ||
return CommentInfo.builder() | ||
.commentId(comment.getId()) | ||
.member(MemberResponse.of(comment.getMember())) | ||
.content(comment.getContent()) | ||
.createdAt(comment.getCreatedAt()) | ||
.build(); | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
backend/memetory/src/main/java/com/example/memetory/domain/comment/dto/CommentInfoList.java
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
backend/memetory/src/main/java/com/example/memetory/domain/comment/dto/CommentInfoSlice.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,29 @@ | ||
package com.example.memetory.domain.comment.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.domain.Slice; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@Schema(description = "댓글 리스트") | ||
public class CommentInfoSlice { | ||
@Schema(description = "현재 페이지") | ||
private int currentPage; | ||
@Schema(description = "다음 페이지 여부") | ||
private boolean hasNext; | ||
|
||
private List<CommentInfo> commentInfoList; | ||
|
||
@Builder | ||
public CommentInfoSlice(int currentPage, boolean hasNext, List<CommentInfo> commentInfoList) { | ||
this.currentPage = currentPage; | ||
this.hasNext = hasNext; | ||
this.commentInfoList = commentInfoList; | ||
} | ||
} |
33 changes: 0 additions & 33 deletions
33
...end/memetory/src/main/java/com/example/memetory/domain/comment/dto/CommentServiceDto.java
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
...emetory/src/main/java/com/example/memetory/domain/comment/dto/request/CommentRequest.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,21 @@ | ||
package com.example.memetory.domain.comment.dto.request; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor | ||
@Builder | ||
@AllArgsConstructor | ||
@Getter | ||
public class CommentRequest { | ||
private String content; | ||
private Long memesId; | ||
private String email; | ||
|
||
public void setMemesIdAndEmail(Long memesId, String email) { | ||
this.memesId = memesId; | ||
this.email = email; | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
...src/main/java/com/example/memetory/domain/comment/dto/request/GenerateCommentRequest.java
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
...tory/src/main/java/com/example/memetory/domain/comment/repository/CommentQDtoFactory.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,20 @@ | ||
package com.example.memetory.domain.comment.repository; | ||
|
||
import static com.example.memetory.domain.comment.entity.QComment.*; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.example.memetory.domain.comment.dto.QCommentInfo; | ||
import com.example.memetory.domain.member.dto.response.QMemberResponse; | ||
|
||
@Component | ||
public class CommentQDtoFactory { | ||
|
||
@Bean | ||
public QCommentInfo qCommentInfo() { | ||
return new QCommentInfo(comment.id, | ||
new QMemberResponse(comment.member.id, comment.member.nickname, comment.member.imageUrl, comment.member.createdAt), | ||
comment.content, comment.createdAt); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
.../src/main/java/com/example/memetory/domain/comment/repository/CommentQueryRepository.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,10 @@ | ||
package com.example.memetory.domain.comment.repository; | ||
|
||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Slice; | ||
|
||
import com.example.memetory.domain.comment.dto.CommentInfo; | ||
|
||
public interface CommentQueryRepository { | ||
Slice<CommentInfo> findCommentsSliceByMemesId(Long memesId, Pageable pageable); | ||
} |
45 changes: 45 additions & 0 deletions
45
.../main/java/com/example/memetory/domain/comment/repository/CommentQueryRepositoryImpl.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,45 @@ | ||
package com.example.memetory.domain.comment.repository; | ||
|
||
import static com.example.memetory.domain.comment.entity.QComment.*; | ||
import static com.example.memetory.domain.member.entity.QMember.*; | ||
import static com.example.memetory.domain.memes.entity.QMemes.*; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Slice; | ||
import org.springframework.data.domain.SliceImpl; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import com.example.memetory.domain.comment.dto.CommentInfo; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class CommentQueryRepositoryImpl implements CommentQueryRepository { | ||
private final JPAQueryFactory jpaQueryFactory; | ||
private final CommentQDtoFactory commentQDtoFactory; | ||
|
||
@Override | ||
public Slice<CommentInfo> findCommentsSliceByMemesId(Long memesId, Pageable pageable) { | ||
int pageSize = pageable.getPageSize(); | ||
List<CommentInfo> memesList = jpaQueryFactory.select(commentQDtoFactory.qCommentInfo()) | ||
.from(comment) | ||
.where(comment.memes.id.eq(memesId)) | ||
.join(comment.member, member) | ||
.join(comment.memes, memes) | ||
.offset(pageable.getOffset()) | ||
.limit(pageSize + 1) | ||
.fetch(); | ||
|
||
boolean hasNext = false; | ||
if (memesList.size() > pageSize) { | ||
memesList.remove(pageSize); | ||
hasNext = true; | ||
} | ||
|
||
return new SliceImpl<>(memesList, pageable, hasNext); | ||
} | ||
} |
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.