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

[Spring MVC] 한경준 미션 제출합니다. #42

Open
wants to merge 9 commits into
base: hkjbrian
Choose a base branch
from

Conversation

hkjbrian
Copy link

안녕하세요 리뷰어님 step2~3 완료 후 다시 PR을 생성하는게 리뷰하기 편할 것 같아서 새로 PR을 만들었습니다.

중점적으로 봐주셨으면 하는 내용

  1. HandlerInterceptor 와 ArgumentResolver의 사용이 적절한지
  2. 미션의 요구사항을 모두 만족했는지
  3. 추가로 MemberService에 로그인에 대한 처리를 맡겼는데 원래 Auth 패키지 내부에 AuthService와 AuthController를 통해서 따로 인증을 처리하고 싶었는데, 미션을 진행하다보니 패키지끼리 의존성이 높아지는 것을 느꼈고, 특히 MemberDao를 통해서 DB에 접근할 때 불편한 점이 많아지는 것 같았는데 이 부분 어떻게 고민하셨는지 궁금합니다.

Copy link

@PlusUltraCode PlusUltraCode left a comment

Choose a reason for hiding this comment

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

안녕하세요 경준님 리뷰어 이동호입니다.
리뷰가 늦은 이유는 MVC 미션 관련해서 많이 부족하여
추가적으로 공부한 뒤 리뷰해야 될거 같아서 오늘 리뷰드렸습니다.

늦은점 죄송합니다

추가적으로 패키지 분리에 대해서 말해보고 싶습니다.
auth라는 패키지 안에 인터셉터/web/LoginRequest/Token 등 많은 클래스가 있다고 생각됩니다.
auth패키지 안에 추가적으로 web.pakage / Token.pakage 등 세부적으로 나눠서 관리하는게 어떨지 아니면 다르 경로에 여러개의 패키지를 만들어 관리할 지 경준님의 의견의 궁금합니다 : )

Comment on lines +13 to +26
public class AdminInterceptor implements HandlerInterceptor {
private final MemberDao memberDao;
private final MemberService memberService;

public AdminInterceptor(MemberDao memberDao, MemberService memberService) {
this.memberDao = memberDao;
this.memberService = memberService;
}

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Long memberId = memberService.checkLogin(request).getId();
Member member = memberDao.findById(memberId);

Choose a reason for hiding this comment

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

MemberDao 는 데이터베이스와 직접적으로 소통하는 객채입니다.

Interceptor 클래스에서 MemberDao를 직접 소환하는게 아닌 memberService만 소환하여
member 객체를 찾는 방법은 어떨까요? : )

Comment on lines +10 to +11
private String secretKey = "Yn2kjibddFAWtnPJ2AFlL8WXmohJMCvigQggaEypa5E=";

Choose a reason for hiding this comment

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

직접적으로 토큰키를 명시하기 보다는 application.yaml 파일에 있는 내용을 가지고 오는건 어떨가요??

hint : @value 어노테이션 : )

Comment on lines +28 to 42
if (reservationRequest.name() == null) {
reservationRequest = new ReservationRequest(
loginMember.getName(),
reservationRequest.date(),
reservationRequest.theme(),
reservationRequest.time()
);
}

if (reservationRequest.name() == null
|| reservationRequest.date() == null
|| reservationRequest.theme() == null
|| reservationRequest.time() == null) {
return ResponseEntity.badRequest().build();
}

Choose a reason for hiding this comment

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

순서를 바꾸고 코드를 작게 수정하면
중복되는 코드없이 더 효율적으로 작성할 수 있을거 같아요 :)

Comment on lines +35 to +41
@GetMapping("/login/check")
public ResponseEntity<LoginMember> loginCheck(HttpServletRequest request) {

LoginMember loginMember = memberService.checkLogin(request);

return ResponseEntity.ok().body(loginMember);
}

Choose a reason for hiding this comment

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

단계가 넘어가서 수정이 안된거 같지만
경준님께서 만드신 @authentication 을 활용해보는게 어떨가요??

Comment on lines +8 to +11
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
public @interface Authentication {
}

Choose a reason for hiding this comment

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

이 부분은 궁금하네요
@annotation 으로 만들지 않고 @interface 로 만드신 이유가 있나요?

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.

2 participants