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

[Feat] #18 피드 CRUD 기능 구현 #18

Merged
merged 66 commits into from
Nov 5, 2024
Merged

Conversation

seokjun01
Copy link
Collaborator

1. 무슨 이유로 코드를 변경했나요?


첫 기능 개발시, 엔티티 클래스 구조를 제대로 잡지 않고 개발을 시작하여 갈수록 꼬이는 현상이 발생하여서
처음부터 엔티티 클래스 구현-> 관계 매핑 ->DTO 구현 서비스 로직 구현 -> 컨트롤러 구현 이런 순서로 개발을 진행하였습니다!

2. 어떤 위험이나 장애를 발견했나요?


현재 push 된 코드에서 포스트맨에서 테스트를 해 본 결과, 좋아요 추가 기능에서 추가는 잘 돌아갔다고 뜨나, 좋아요를 취소하는 요청을 테스트 해보면, 좋아요가 눌리지 않은 게시물이라고 뜹니다.
원래라면 좋아요가 취소 되었습니다. 라는 응답이 떠야 정상입니다.
이 부분에 대해서 피드백 주시면 수정 하겠습니다

3. 관련 스크린샷을 첨부해주세요.


스크린샷 2024-11-01 오후 11 22 22 스크린샷 2024-11-01 오후 10 44 45

4. 완료 사항


현재 글 생성, 글 조회, 좋아요 수로 정렬한 게시물 조회, 최신 게시물 조회, 좋아요 추가 , 좋아요 삭제, 글 삭제 등등의 기능을 구현하였으며
글 인용 ,리트윗 기능을 추가로 구현하여야합니다.

5. 추가 사항

@seokjun01 seokjun01 added the feat 기능 개발, 구현 label Nov 1, 2024
@seokjun01 seokjun01 requested a review from hyxklee November 1, 2024 14:25
Copy link
Member

@hyxklee hyxklee left a comment

Choose a reason for hiding this comment

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

수정하시느라 고생하셨어요!
likeCount를 계산하는 부분과 해당 코멘트 정도만 수정되면 될 것 같아요!
조금만 더 힘내주세욥

@RestController
@RequestMapping("/api/v1/posts")
@RequiredArgsConstructor
public class PostController {
Copy link
Member

Choose a reason for hiding this comment

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

@tag, @operation 어노테이션을 이용해 스웨거 설명도 추가해주시면 좋을 것 같아요!

// 게시물 ID로 조회
@GetMapping("/{id}")
public ResponseDto<PostResponseDto> getPost(@PathVariable Long id) {
return postService.getPostResponse(id);
Copy link
Member

Choose a reason for hiding this comment

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

응답 객체, 즉 ResponseDto를 만들고, 안에 코드를 넣고, 메시지를 넣는 책임. 즉 응답에 관련된 책임은 controller 단에서 하는 것이 좋다고 생각해요!
따라서 서비스 단에서 ResponseDto를 만들어서 그대로 반환하기 보다,

@GetMapping("/{id}")
    public ResponseDto<PostResponseDto> getPost(@PathVariable Long id) {
        return ResponseDto.response(응답 코드, 응답 메시지, postService.getPostResponse(id));
}

이렇게 구현하는 것은 어떨까요??

private List<Image> images = new ArrayList<>();

@OneToMany(mappedBy = "post", cascade = CascadeType.REMOVE, orphanRemoval = true)
private List<Comment> commentList = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

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

ERD가 수정이 되어서 Comment가 사라지고, Post의 자기 참조로 reply를 구현하게 되어 있어서 Comment 도메인은 제거해도 될 것 같아요!

Copy link
Member

@hyxklee hyxklee left a comment

Choose a reason for hiding this comment

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

해당 부분 수정하고 머지해주세요!

public PostResponseDto createPost(PostRequestDTO postRequestDTO, String email) {
// 이메일로 사용자 조회
User user = userService.find(email); // JWT에서 추출한 이메일 사용
if (user == null) {
Copy link
Member

Choose a reason for hiding this comment

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

userService.fin() 메서드에서 이미 null checking을 해주고 있기 때문에 따로 해주지 않아도 됩니다! if문 제거 부탁드릴게요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 제거하였습니다!

@seokjun01 seokjun01 merged commit 9ae6678 into main Nov 5, 2024
2 checks passed
@seokjun01 seokjun01 deleted the feat/#15/CRUD-기능-구현 branch November 5, 2024 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat 기능 개발, 구현
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants