Skip to content
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

모임 댓글 기능 구현 #169

Merged
merged 21 commits into from
Aug 1, 2024
Merged

모임 댓글 기능 구현 #169

merged 21 commits into from
Aug 1, 2024

Conversation

ay-eonii
Copy link
Contributor

@ay-eonii ay-eonii commented Aug 1, 2024

PR의 목적이 무엇인가요?

모임 댓글 기능을 구현합니다.

이슈 ID는 무엇인가요?

설명

  • 상세 조회 API response에 comments 추가
{
    "data": {
        "title": "string",
        ...
        "comments": [
            {
                "commentId": 3,
                "nickname": "string",
                "content": "string",
                "dateTime": "2024-07-31 19:24",
                "childs": [
                    {
                        "commentId": 13,
                        "nickname": "string",
                        "content": "자식",
                        "dateTime": "2024-07-31 00:00"
                    },
                    {
                        "commentId": 14,
                        "nickname": "string",
                        "content": "자식",
                        "dateTime": "2024-07-31 00:00"
                    }
                ]
            },
            {
                "commentId": 4,
                "nickname": "string",
                "content": "string",
                "dateTime": "2024-07-31 19:24",
                "childs": []
            }
        ]
    }
}
  • 댓글 작성 기능

질문 혹은 공유 사항 (Optional)

@ay-eonii ay-eonii added BE 백엔드 관련 이슈입니다. 🌱 기능추가 feature (새로운 기능 구현) labels Aug 1, 2024
@ay-eonii ay-eonii self-assigned this Aug 1, 2024
@ay-eonii ay-eonii linked an issue Aug 1, 2024 that may be closed by this pull request
5 tasks
Copy link
Contributor

@Mingyum-Kim Mingyum-Kim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고했어요 아연씨 ~
리뷰 가볍게 체크 부탁드려요 😋

Comment on lines 26 to 39
@JoinColumn(name = "moim_id")
private Moim moim;

@ManyToOne
@JoinColumn(name = "member_id")
private Member member;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거는 @Column(nullable = false) 를 안해줘도 되나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

필요한 것 같아요@ManyToOne가 있어 @JoinColum(nullable = false)로 하겠습니다~!

}

private void validateContent(String content) {
if (content == null || content.isBlank()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

content.isBlank() 에 null check가 포함되어있는 걸로 아는데요 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

정보 공유용~

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헤헷콩 감사합니다

Comment on lines 64 to 68
private void validateMoim(Moim moim) {
if (moim == null) {
throw new MoimException(HttpStatus.NOT_FOUND, MoimErrorMessage.NOT_FOUND);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

댓글 저장 시 잘못된 모임을 입력해서 에러가 발생했는데, MoimException을 발생시키는 게 적절할까요? 고민해봅시다!

Comment on lines +18 to +19
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
LocalDateTime dateTime
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

데이터베이스에서는 date time으로 따로 저장되어있는데
여기는 한번에 보내네요! 이유가 있을까요?

LocalDateTime으로 보내면 상돌이 설정한 JacksonConfig가 적용되지 않는군요 .. 한번에 JacksonConfig에서 포맷팅할 수 없을까요?


private void validateMember(Member member) {
if (member == null) {
throw new CommentException(HttpStatus.NOT_FOUND, CommentErrorMessage.MEMBER_NOT_FOUND);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기에서는 회원이 없을 때 CommentException이 발생하는데, 위와 컨벤션이 맞지 않는 것 같네요.

Comment on lines 74 to 82
List<Comment> comments = commentRepository.findAllByMoimIdOrderByCreatedAt(id);
Map<Long, List<Comment>> childComments = comments.stream()
.filter(Comment::isChild)
.collect(groupingBy(Comment::getParentId));

List<CommentResponse> commentResponses = comments.stream()
.filter(Comment::isParent)
.map(comment -> CommentResponse.toResponse(comment, findChildComments(comment, childComments)))
.toList();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분이 무슨 역할을 담당하는 지 이해하기 힘든 것 같아요. 메서드 분리해서 가독성을 높여주면 좋겠어용

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나중에 테스트 픽스처를 사용하는 것으로 수정해주면 좋겠어요!
다른 도메인들도 픽스처를 사용하기로 해서요.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오잉 픽스처가 있네요 .. 😀
왜 하나만 생성해두었는 지 궁금하네요 👍

Copy link
Contributor Author

@ay-eonii ay-eonii Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null 같은 값이 부분적으로 들어가야해서 픽스쳐 사용하지 않았어용 픽스쳐는 자식 댓글 하나 추가할게용

Copy link
Contributor

@ksk0605 ksk0605 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

간단한 코멘트니까 넘어가도 돼요!

Comment on lines 32 to 44
@Column(nullable = false)
private String content;

@ManyToOne
@JoinColumn(name = "moim_id")
private Moim moim;

@ManyToOne
@JoinColumn(name = "member_id")
private Member member;

@Column(nullable = false)
private LocalDateTime createdAt;

private Long parentId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

널이 가능한 컬럼과 아닌 컬럼이 나뉘어 있는데 제가 볼 때는 모든 정보다 다 null 이면 안되는 값 같아보여서요!

@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
LocalDateTime dateTime,

List<ChildCommentResponse> childs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ㅋㅋ? child의 복수형은 children 아닌가요?

Comment on lines 42 to 45

public Moim createMoim(MoimCreateRequest moimCreateRequest) {
Member author = new Member(moimCreateRequest.authorNickname());
Moim moim = moimRepository.save(moimCreateRequest.toEntity());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

builder 로 생성하지 않고 생성자를 선택하신 이유가 있나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오호라


public record CommentCreateRequest(
Long parentId,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

파라미터 요거 개행하나요?


@Override
@PostMapping("/{moimId}")
public ResponseEntity<Void> createComment(@LoginMember Member member, @PathVariable Long moimId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

파라미터 3개 이상이면 줄바꿈 해야할 것 같습니다! 컨벤션에 적혀있더라구요!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감삼당 👍

Copy link
Contributor

@hoyeonyy hoyeonyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생많았습니다 테니! 코드량이 쫌 많긴 하네요!

사소한 컨벤션 몇개 남겨놨습니다!

Copy link
Contributor

@Mingyum-Kim Mingyum-Kim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

피드백 잘 반영해주셔서 감사합니다><
어푸르브 드려요 >
<

@ay-eonii ay-eonii merged commit d4ce086 into develop-backend Aug 1, 2024
1 check passed
@ay-eonii ay-eonii deleted the feature/#151 branch August 1, 2024 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE 백엔드 관련 이슈입니다. 🌱 기능추가 feature (새로운 기능 구현)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

댓글 기능 구현
4 participants