-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from kakao-tech-campus-2nd-step3/Master
14조 코드리뷰 4회차
- Loading branch information
Showing
24 changed files
with
418 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/com/ordertogether/team14_be/common/web/handler/GlobalExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.ordertogether.team14_be.common.web.handler; | ||
|
||
import com.ordertogether.team14_be.member.application.exception.NotFoundMember; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@RestControllerAdvice | ||
public class GlobalExceptionHandler { | ||
|
||
@ExceptionHandler(NotFoundMember.class) | ||
@ResponseStatus(HttpStatus.CONFLICT) | ||
public ResponseEntity<String> handleAlreadyExistMemberException(NotFoundMember e) { | ||
return ResponseEntity.status(HttpStatus.CONFLICT).body(e.getMessage()); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/ordertogether/team14_be/config/WebConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.ordertogether.team14_be.config; | ||
|
||
import com.ordertogether.team14_be.member.application.LoginMemberArgumentResolver; | ||
import java.util.List; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
public class WebConfig implements WebMvcConfigurer { | ||
private final LoginMemberArgumentResolver loginMemberArgumentResolver; | ||
|
||
public WebConfig(LoginMemberArgumentResolver loginMemberArgumentResolver) { | ||
this.loginMemberArgumentResolver = loginMemberArgumentResolver; | ||
} | ||
|
||
@Override | ||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) { | ||
argumentResolvers.add(loginMemberArgumentResolver); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...main/java/com/ordertogether/team14_be/member/application/LoginMemberArgumentResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.ordertogether.team14_be.member.application; | ||
|
||
import com.ordertogether.team14_be.auth.JwtUtil; | ||
import com.ordertogether.team14_be.member.application.service.MemberService; | ||
import com.ordertogether.team14_be.member.persistence.MemberRepository; | ||
import com.ordertogether.team14_be.member.presentation.LoginMember; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.core.MethodParameter; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.support.WebDataBinderFactory; | ||
import org.springframework.web.context.request.NativeWebRequest; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.method.support.ModelAndViewContainer; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class LoginMemberArgumentResolver implements HandlerMethodArgumentResolver { | ||
|
||
private final MemberService memberService; | ||
private final MemberRepository memberRepository; | ||
private final JwtUtil jwtUtil; | ||
|
||
@Override | ||
public boolean supportsParameter(MethodParameter parameter) { | ||
boolean hashLoginUserAnnotation = parameter.hasParameterAnnotation(LoginMember.class); | ||
return hashLoginUserAnnotation; | ||
} | ||
|
||
@Override | ||
public Object resolveArgument( | ||
MethodParameter parameter, | ||
ModelAndViewContainer mavContainer, | ||
NativeWebRequest webRequest, | ||
WebDataBinderFactory binderFactory) | ||
throws Exception { | ||
|
||
String token = webRequest.getHeader(HttpHeaders.AUTHORIZATION).substring(7); | ||
String memberIdString = jwtUtil.decodeJwt(token).getSubject(); | ||
Long memberId = Long.parseLong(memberIdString); | ||
|
||
return memberService.findMember(memberId); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/java/com/ordertogether/team14_be/member/application/dto/MemberInfoRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.ordertogether.team14_be.member.application.dto; | ||
|
||
public record MemberInfoRequest(String deliveryName, String phoneNumber) {} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/ordertogether/team14_be/member/application/dto/MemberInfoResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.ordertogether.team14_be.member.application.dto; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record MemberInfoResponse(String deliveryName, String phoneNumber, int point) {} |
3 changes: 3 additions & 0 deletions
3
src/main/java/com/ordertogether/team14_be/member/application/dto/MemberSignUpRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.ordertogether.team14_be.member.application.dto; | ||
|
||
public record MemberSignUpRequest(String token, MemberInfoRequest memberInfoRequest) {} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/ordertogether/team14_be/member/application/exception/NotFoundMember.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.ordertogether.team14_be.member.application.exception; | ||
|
||
import java.util.NoSuchElementException; | ||
|
||
public class NotFoundMember extends NoSuchElementException { | ||
|
||
public NotFoundMember() { | ||
super("회원정보가 존재하지 않습니다"); | ||
} | ||
} |
65 changes: 55 additions & 10 deletions
65
src/main/java/com/ordertogether/team14_be/member/application/service/MemberService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.