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주차] 기본과제 제출 #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

[2주차] 기본과제 제출 #2

wants to merge 3 commits into from

Conversation

sunseo18
Copy link
Collaborator

기본 과제

  • 그냥 세미나 시간에 했던거 복습!

심화 과제

  • 다 하면 적을게욤

@sunseo18 sunseo18 changed the title [2주차] 기본/심화과제 [2주차] 기본/심화과제 제출 Apr 21, 2023
@sunseo18 sunseo18 changed the title [2주차] 기본/심화과제 제출 [2주차] 기본/도전과제 제출 Apr 21, 2023
@sunseo18 sunseo18 marked this pull request as ready for review April 21, 2023 13:13
@sunseo18 sunseo18 changed the title [2주차] 기본/도전과제 제출 [2주차] 기본과제 제출 Apr 21, 2023
Copy link
Member

@PgmJun PgmJun 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
Member

Choose a reason for hiding this comment

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

Animal을 동물의 종류인 Dog라는 이름의 클래스 등으로 상속해서 구현하는데,
그렇다면 종을 뜻하는 species 필드가 필요한 이유가 궁금합니다!
중복되는 내용이 아닌가 싶네요!

Copy link
Member

Choose a reason for hiding this comment

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

배운 제네릭을 잘 활용하였네요~~

Copy link
Member

Choose a reason for hiding this comment

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

null 사용보단 Optional을 이용해보는 것은 어떨까요!?

Copy link
Member

@05AM 05AM left a 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() : "해당 이름을 가진 유저가 없습니다";
Copy link
Member

Choose a reason for hiding this comment

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

return 값으로 optional을 준다면 좋을 것 같습니다!

Comment on lines +31 to +38
public Post search(String title) {
for (Post post : postList) {
if (post.getTitle().equals(title)) {
return post;
}
}
return null;
}
Copy link
Member

Choose a reason for hiding this comment

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

title이 같은 게시물이 여러 개 있을 경우도 생각해본다면 좋을 것 같습니다.

Copy link

@KWY0218 KWY0218 left a comment

Choose a reason for hiding this comment

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

작업하시느라 수고하셨습니다~ !
LGTM 입니담 ~ 😄

Comment on lines +16 to +46
@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() : "해당 제목을 가진 게시물이 없습니다";
}
}
Copy link

Choose a reason for hiding this comment

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

@RequestMapping 을 사용해서 /post 중복을 없애보는 것이 어떨까요~?

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