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

Second seminar #2

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

Second seminar #2

wants to merge 3 commits into from

Conversation

sss4920
Copy link
Collaborator

@sss4920 sss4920 commented Apr 9, 2023

  1. article데이터 형식 정의 & article dto 정의
  2. 게시물 생성 실습
  3. Arraylist의 get 메서드를 이용해 Path Variable로 getOneById 작성
  4. Query Parameter로 searchOneByTitle 작성

@sss4920 sss4920 closed this Apr 10, 2023
@sss4920 sss4920 reopened this Apr 10, 2023
Copy link
Member

@dragontaek-lee dragontaek-lee left a 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){
Copy link
Member

Choose a reason for hiding this comment

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

별거는 아닐수 있지만, SpringBoot에서는 package, 파일명 등.. 카멜케이스를 많이 쓰고는 해요. (articleId)

그리고 userId는 카멜케이스로 썼기 때문에 통일감이 있으면 더 좋을거 같아요!

Copy link
Collaborator Author

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){
Copy link
Member

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("게시물이 존재하지 않습니다.");

Choose a reason for hiding this comment

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

우와 이런 방법이 있군요... 람다를 더 공부해봐야겠네요..! (코드 리뷰하러 와서 배워가는 사람)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

헉 저도 저렇게 구현하는 방법이 있을 줄 몰랐어요! 위 코드에 모르는게 좀 많아서..ㅎ 좀 더 공부해보고 이해가 완벽히 되면 바꿔 올리겠습니다!

Choose a reason for hiding this comment

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

오.. 저도 배워갈게요,,, 👍

Copy link

@funnysunny08 funnysunny08 left a 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){

Choose a reason for hiding this comment

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

오.. 저도 배워갈게요,,, 👍

@sohyundoh
Copy link

수정까지 완벽해요!! 많이 배워갑니다!😄

@sss4920
Copy link
Collaborator Author

sss4920 commented Apr 18, 2023

허걱 감사합니다!!🙈
소현씨도 고생많으셨어요!!

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