-
Notifications
You must be signed in to change notification settings - Fork 14
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
이상윤 API 구축 코드 #9
base: main
Are you sure you want to change the base?
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.
고생하셨습니다 ㅎㅎㅎ👍
private final MemberService memberService; | ||
private final MemberRepository memberRepository; | ||
|
||
@Autowired |
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.
생성자가 한 개인 경우 생략이 가능하군요! 감사합니다!
@@ -0,0 +1,13 @@ | |||
package PKNU.first_spring.controller; | |||
|
|||
public class MemberForm { |
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.
dto로 사용한다면, 차라리 Record를 사용하는게 어떨까요?!
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.
헉 Record 쓰니까 이렇게까지 줄어드네요 감사합니다! 변경 후 노션에 정리해놓겠습니다
return "/members/deleteMemberForm"; | ||
} | ||
|
||
@PostMapping("/members/delete") |
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.
지우는거라면 다른 Mapping이 있지않을까요?
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.
html폼이 delete 메소드를 전송을 못해서 일단 저렇게 했었는데 찾아보니 다른 방법이 있어 수정했습니다. 변경해서 노션에 정리해놓겠습니다!
public Optional<Member> findByName(String name) { | ||
return store.values().stream() | ||
.filter(member -> member.getName().equals(name)) | ||
.findAny(); |
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.
직접 꺼내는것보다.. member,sameName() 으로 바꿀 수 있지 않을까요?
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.
LGTM! 퀴즈 관련으로 만들어주셨네요~! 실제로 작동하는 모습을 노션으로 남겨주시면 감사하겠습니다 결과물이 궁금하네요~!
memberService = new MemberService(memberRepository); | ||
} | ||
@Test | ||
public void 회원삭제(){ |
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.
테스트 코드도 작성해주셨네요! 👍 추후 조금 더 체계적인 테스트 코드를 위해서는 AAA 패턴을 활용해보시는 것도 좋을 것 같아요. assert 구문을 통해 원하는 결과가 아닐 시 테스트가 실패하도록 만드는 것도 중요할 것 같습니다!
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.
감사합니다! 더 공부해서 노션에 추가해보도록 하겠습니다!
<img src="수리2.png" alt="Soori" /> | ||
<img src="수리짤.gif" alt="Soori" /> | ||
<img src="수리짤2.gif" alt="Soori" /> | ||
<p>정답은 귀여운 수리가 있는 한화 이글스 입니다!</p> |
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.
네 ㅎㅎ..
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public class MemberService { |
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.
감사합니다!
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface MemberRepository { |
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.
감사합니다 :)
} | ||
|
||
@GetMapping("/members/new") | ||
public String createForm() { |
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.
api 경로 수정했습니다!
MemberController : 멤버 추가, 조회, 삭제 기능 구현
QuizController : 쉬운 퀴즈 구현