오늘 공부한 것
* 댓글 대댓글 에러코드 수정
* 발표자료에 들어갈 시연 연상 만들기
오늘은 프론트에서 댓글 조회, 마이페이지 댓글 및 대댓글 조회시 에러코드를 바꿔달라고하여서
해당 코드 수정을 했다
1. CommentsService
존재하지 않는 댓글 에러처리에 맞춰서 테스트코드도 주석처리함
// 댓글 조회
public Slice<CommentsResponseDto> commentsList(Long postId,
Pageable pageable) {
Posts posts = postsRepository.findById(postId).orElseThrow(
() -> new CustomException(ErrorCode.POST_NOT_EXIST)); // 존재하지 않는 게시글입니다
Slice<Comments> commentsList = commentsRepository.findByPosts_IdOrderByCreatedAtDesc(postId, pageable);
// if (commentsList.isEmpty()) {
// throw new CustomException(ErrorCode.COMMENTS_NOT_EXIST); // 존재하지 않는 댓글입니다
// }
List<CommentsResponseDto> commentsResponseDtoList = new ArrayList<>();
for (Comments comments : commentsList) {
List<RepliesResponseDto> repliesList = new ArrayList<>();
for (Replies replies : comments.getRepliesList()) {
if (posts.getUsers().getEmail().equals(replies.getEmail())) {
repliesList.add(new RepliesResponseDto(replies, "글쓴이"));
} else {
repliesList.add(new RepliesResponseDto(replies));
}
}
if (posts.getUsers().getEmail().equals(comments.getEmail())) {
commentsResponseDtoList.add(new CommentsResponseDto(comments, "글쓴이", repliesList));
} else {
commentsResponseDtoList.add(new CommentsResponseDto(comments, repliesList));
}
}
return new SliceImpl<>(commentsResponseDtoList, pageable, commentsList.hasNext());
}
// 마이페이지에서 내가 쓴 댓글 조회
public Slice<CommentsMeResponseDto> commentsMeList (Users users,
Pageable pageable) {
Slice<Comments> commentsMeList = commentsRepository.findAllByAndEmailOrderByCreatedAtDesc(users.getEmail(), pageable);
// if (commentsMeList.isEmpty()) {
// throw new CustomException(ErrorCode.COMMENTS_NOT_EXIST); // 존재하지 않는 댓글입니다
// }
List<CommentsMeResponseDto> CommentsMeResponseDtoList = new ArrayList<>();
for (Comments comments : commentsMeList) {
CommentsMeResponseDtoList.add(new CommentsMeResponseDto(comments, comments.getPosts().getTitle()));
}
return new SliceImpl<>(CommentsMeResponseDtoList, pageable, commentsMeList.hasNext());
}
2. RepliesService
존재하지 않는 댓글 에러처리에 맞춰서 테스트코드도 주석처리함
// 마이페이지에서 내가 쓴 대댓글 조회
public Slice<RepliesMeResponseDto> repliesMeList(Users users,
Pageable pageable) {
Slice<Replies> repliesMeList = repliesRepository.findAllByAndEmailOrderByCreatedAtDesc(users.getEmail(), pageable);
// if (repliesMeList.isEmpty()) {
// throw new CustomException(ErrorCode.REPLIES_NOT_EXIST); // 존재하지 않는 대댓글입니다
// }
List<RepliesMeResponseDto> RepliesMeResponseDtoList = new ArrayList<>();
for (Replies replies : repliesMeList) {
RepliesMeResponseDtoList.add(new RepliesMeResponseDto(replies, replies.getComments().getPosts().getTitle()));
}
return new SliceImpl<>(RepliesMeResponseDtoList, pageable, repliesMeList.hasNext());
}
이후 1차 발표 영상에 들어갈 2분 30초 짜리 시연 영상 제작에 들어갔다
녹화는 OBS Studio 프로그램을 사용하여 진행했고 편집은 Clipchamp 로 하였다
자르고 이어 붙이고 자막까지 처음이어서 시간을 좀 오래걸렸지만 나름 만족스러운 결과물이 나왔다
'항해99' 카테고리의 다른 글
23.11.06~11.12 항해 99 16기 12주차 회고록 (1) | 2023.11.12 |
---|---|
23.11.11 항해 99 16기 실전 프로젝트 34일차 (0) | 2023.11.11 |
23.11.09 항해 99 16기 실전 프로젝트 32일차 (0) | 2023.11.09 |
23.11.08 항해 99 16기 실전 프로젝트 31일차 (0) | 2023.11.08 |
23.11.07 항해 99 16기 실전 프로젝트 30일차 (0) | 2023.11.07 |