-
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
Second seminar #2
base: main
Are you sure you want to change the base?
Conversation
sss4920
commented
Apr 9, 2023
- article데이터 형식 정의 & article dto 정의
- 게시물 생성 실습
- Arraylist의 get 메서드를 이용해 Path Variable로 getOneById 작성
- Query Parameter로 searchOneByTitle 작성
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 "게시물이 존재하지 않습니다."; | ||
|
||
} | ||
public String searchByArticleId(Long article_id){ |
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.
별거는 아닐수 있지만, SpringBoot에서는 package, 파일명 등.. 카멜케이스를 많이 쓰고는 해요. (articleId)
그리고 userId는 카멜케이스로 썼기 때문에 통일감이 있으면 더 좋을거 같아요!
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 newArticle.getId(); | ||
} | ||
public String searchByArticleTitle(String 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.
stream()을 활용하면 더 간결하고 멋진 코드가 될거 같아요!
제가 직접 돌려보지는 않아서 맞을지는 모르겠어요. 한번 검색해 보시고 적용해보시면 나중에도 많이 쓰이니 좋을거 같아요!
Optional<Article> article = articleList.stream()
.filter(a -> a.getTitle().equals(title))
.findFirst();
return article.map(a -> "id=" + a.getId() + "\n title=" + a.getTitle() + "\n text=" + a.getText())
.orElse("게시물이 존재하지 않습니다.");
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.
헉 저도 저렇게 구현하는 방법이 있을 줄 몰랐어요! 위 코드에 모르는게 좀 많아서..ㅎ 좀 더 공부해보고 이해가 완벽히 되면 바꿔 올리겠습니다!
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.
세미나 때 배운 내용들을 골고루 잘 녹여낸 것 같아요!! 저도 복습 많이 됐습니다 ㅎ.ㅎ
수고하셨어용!!
// 저장한 유저 아이디 값 반환 | ||
return newArticle.getId(); | ||
} | ||
public String searchByArticleTitle(String 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.
오.. 저도 배워갈게요,,, 👍
수정까지 완벽해요!! 많이 배워갑니다!😄 |
허걱 감사합니다!!🙈 |