-
Notifications
You must be signed in to change notification settings - Fork 0
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차 세미나 기본과제 #5
base: main
Are you sure you want to change the base?
2차 세미나 기본과제 #5
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니당 <3
import static sopt.org.secondSeminar.SecondSeminarApplication.postList; | ||
|
||
@RestController | ||
@RequestMapping("/post") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
공통적인 URI 매핑 따로뺀 거 아주 좋군녀
public class ResGetPost { | ||
private Long postId; | ||
private Long authorId; | ||
private String title; | ||
private String content; | ||
private String registeredDate; | ||
private String updatedDate; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Response dto도 만들었네요 !! 👍👍
현재 Response dto는 Post 객체의 데이터 그대로 리턴하고 있어서 status code와 같은 유의미한 정보를 추가하거나
아니면 Response Dto 없이 바로 Post 객체를 넘겨주는 것도 좋을 거 같군요 : )
postList.get((int)postId - 1).getPostId(), | ||
postList.get((int)postId - 1).getAuthorId(), | ||
postList.get((int)postId - 1).getTitle(), | ||
postList.get((int)postId - 1).getContent(), | ||
postList.get((int)postId - 1).getRegisteredDate(), | ||
postList.get((int)postId - 1).getUpdatedDate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
postList에서 특정 post 한 번 가져오고, 거기서 필요한 데이터 가져오는 방식으로 하면 더 깔끔할 거 같아요!
Post post = postList.get((int)postId - 1);
ResGetPost resGetPostById = new ResGetPost(
post.getPostId(),
post.getAuthorId(),
post.getTitle(),
post.getContent(),
post.getRegisteredDate(),
post.getUpdatedDate()
);
또, ResGetPost에서도 언급 했듯이 Response dto가 Post의 정보만을 갖고 있기 때문에 ResGetPost를 새로 생성해서 리턴하기보다는 그냥 Post 그대로 리턴해도 될 거 같아요!
return post.toString();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
과제하시느라 고생하셨습니다 ~ !
LGTM 입니다~! 😄
Seminar2/SecondSeminar/src/main/java/sopt/org/secondSeminar/controller/post/PostController.java
Outdated
Show resolved
Hide resolved
…ntroller/post/PostController.java - postmapping literal 수정 Co-authored-by: 강원용 <[email protected]>
…anMi into assignment2 브런치 실수 수정
##구현 내용
기본 과제
PostController
[POST]localhost:8080/post
[GET]localhost:8080/post/:postId
[GET]localhost:8080/post?title={게시물 제목}