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

[2주차] 최서현 : 게시글 조회/생성 api #8

Open
wants to merge 6 commits into
base: choiseohyeon
Choose a base branch
from

Conversation

candosh
Copy link
Member

@candosh candosh commented May 26, 2024

게시글 조회/생성 api

@candosh candosh changed the title [feat] 게시물 조회/생성 기능 [feat] 최서현 2주차 과제 May 26, 2024
@candosh candosh self-assigned this May 26, 2024
@candosh candosh changed the title [feat] 최서현 2주차 과제 [2주차] 게시글 조회/생성 api - 최서현 May 26, 2024
@candosh candosh changed the title [2주차] 게시글 조회/생성 api - 최서현 [2주차] 최서현 : 게시글 조회/생성 api May 26, 2024
@Oilwoo
Copy link

Oilwoo commented May 27, 2024

과제 요구조건 잘 지켜서 잘 코딩해주신 것 같아요! 👍👍
image
저는 createPost 생성해주는부분을 Post 클래스에 Dto로 변환해주는 부분(Entitiy를 DTO로 변환하듯이)을 넣어서 조금 더 깔끔하게 코딩해봤는데 서현님도 적용해보시는 건 어떨까유
image

@shon5544
Copy link
Member

shon5544 commented May 27, 2024

image base 브랜치가 main으로 되어있는데 개인 브랜치로 바꿔주세요!

@candosh candosh changed the base branch from main to choiseohyeon May 27, 2024 11:21
@candosh
Copy link
Member Author

candosh commented May 27, 2024

@Oilwoo 일우님 코드 엄청 깔끔하게 짜신 거 같아요! closed에 슬쩍 가서 참고해보겠습니다!

@shon5544 하위로 feat/week2 팠었는데, 로컬에서 seohyeon에 머지를 하고 seohyen을 올려버렸네용! choiseohyeon을 새로 브랜치 팠습니당! 담부터는 조심🥹


public List<PostDto> getAllPosts() {
List<Post> posts = postRepository.findAll();
return posts.stream().map(PostDto::from).collect(Collectors.toList());
Copy link
Collaborator

Choose a reason for hiding this comment

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

List 엔티티 객체를 dto로 변환하는 것도 따로 빼서 메소드로 만들어주면 좋을 것 같아요!

Comment on lines +17 to +25
public static PostDto from(Post post) {
return PostDto.builder()
.id(post.getId())
.title(post.getTitle())
.content(post.getContent())
.createdAt(post.getCreatedAt())
.updatedAt(post.getUpdatedAt())
.build();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

indent가 8개, 4개가 혼용되고 있네요. 4자로 일정하면 좋을 것 같아요. 인텔리제이 Actions on save 설정하면 설정한 indent 수로 자동 포맷팅을 해줍니다:)

@RestController
@RequestMapping("/posts")
public class PostController {
@Autowired
Copy link
Collaborator

Choose a reason for hiding this comment

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

스프링이 자동으로 injection을 해주기 때문에 @Autowired는 빼도 됩니다. 전에 범수님이 발표한 것처럼 빌드타임에서의 오류를 잡기 힘들다던가 하는 점들이 있어서 이런 상황에서는 안쓰는게 좋아요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants