-
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주차] 기본과제 제출 #2
base: main
Are you sure you want to change the base?
Conversation
* 프로젝트 명 javaPractice로 바꾸고 싶다,,
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.
수고했다 준서!!!
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.
Animal을 동물의 종류인 Dog라는 이름의 클래스 등으로 상속해서 구현하는데,
그렇다면 종을 뜻하는 species 필드가 필요한 이유가 궁금합니다!
중복되는 내용이 아닌가 싶네요!
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.
배운 제네릭을 잘 활용하였네요~~
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.
null 사용보단 Optional을 이용해보는 것은 어떨까요!?
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.
깔끔한 코드 잘 봤습니다!👍
심화 과제 기대해도 되나요?ㅎㅎ
User user = userService.search(name); | ||
// System.out.println("유저 이름 검색 인자: " + name); | ||
|
||
return user != null ? user.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.
return 값으로 optional을 준다면 좋을 것 같습니다!
public Post search(String title) { | ||
for (Post post : postList) { | ||
if (post.getTitle().equals(title)) { | ||
return post; | ||
} | ||
} | ||
return null; | ||
} |
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.
title이 같은 게시물이 여러 개 있을 경우도 생각해본다면 좋을 것 같습니다.
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 입니담 ~ 😄
@RestController | ||
@RequiredArgsConstructor | ||
public class PostController { | ||
private final PostService postService; | ||
|
||
@PostMapping("/post") | ||
public String register(@RequestBody final RegisterRequestDto request) { | ||
// 서비스 계층에 유저를 등록하는 메서드를 호출 | ||
Long postId = postService.register(request); | ||
// System.out.println(postList.get(postId.intValue() - 1).toString()); | ||
|
||
return postId + "번 게시물이 등록되었습니다!"; | ||
} | ||
|
||
@GetMapping("/post/{postId}") | ||
public String getOne(@PathVariable final Long postId) { | ||
Post post = postService.getOne(postId); | ||
// System.out.println("요청 유저 아이디: " + userId); | ||
|
||
return post != null ? post.toString() : "해당 게시물이 존재하지 않습니다"; | ||
} | ||
|
||
|
||
@GetMapping("/post/search") | ||
public String search(@RequestParam final String title) { | ||
Post post = postService.search(title); | ||
// System.out.println("유저 이름 검색 인자: " + name); | ||
|
||
return post != null ? 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.
@RequestMapping 을 사용해서 /post
중복을 없애보는 것이 어떨까요~?
기본 과제
심화 과제