-
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
[feat] EventUserArgumentResolver 적용 및 FE 요청에 따른 추가 API 구현 (#35) #38
Changes from all commits
59eaf16
e0fe948
b1fc018
17c0ad2
fd263e3
4a095b9
96903b0
7c50d87
732743c
b4f81dc
5348547
9c856c1
d52bd05
2063d85
5864bea
7fba82c
191b4ff
2f7cf59
7fa66a1
81b36a2
149dead
bf64b81
3348767
70bd40b
c6296c0
544357d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
import hyundai.softeer.orange.admin.component.AdminArgumentResolver; | ||
import hyundai.softeer.orange.core.auth.AuthInterceptor; | ||
import hyundai.softeer.orange.eventuser.component.EventUserArgumentResolver; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
|
@@ -10,13 +12,13 @@ | |
|
||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@Configuration | ||
public class WebConfig implements WebMvcConfigurer { | ||
@Autowired | ||
private AuthInterceptor authInterceptor; | ||
|
||
@Autowired | ||
private AdminArgumentResolver adminArgumentResolver; | ||
private final AuthInterceptor authInterceptor; | ||
private final AdminArgumentResolver adminArgumentResolver; | ||
private final EventUserArgumentResolver eventUserArgumentResolver; | ||
Comment on lines
+15
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 필드 주입이 3개 이상이라 생성자 주입으로 바꾸었습니다. |
||
|
||
@Override | ||
public void addInterceptors(InterceptorRegistry registry) { | ||
|
@@ -28,5 +30,6 @@ public void addInterceptors(InterceptorRegistry registry) { | |
@Override | ||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) { | ||
resolvers.add(adminArgumentResolver); | ||
resolvers.add(eventUserArgumentResolver); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,14 @@ | |
import hyundai.softeer.orange.core.jwt.JWTManager; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.method.HandlerMethod; | ||
import org.springframework.web.servlet.HandlerInterceptor; | ||
|
||
import java.util.*; | ||
|
||
@Slf4j | ||
@Component // 문제 있으면 변경 | ||
public class AuthInterceptor implements HandlerInterceptor { | ||
private final JWTManager jwtManager; | ||
|
@@ -21,6 +23,11 @@ public AuthInterceptor(JWTManager jwtManager) { | |
|
||
@Override | ||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | ||
// 유효하지 않은 요청은 정적 리소스로 간주하여 ResourceHttpRequestHandler가 대신 처리하기에, HandlerMethod가 아닌 경우는 무시 | ||
if (!(handler instanceof HandlerMethod)) { | ||
return true; | ||
} | ||
|
||
Comment on lines
+26
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 404가 발생해야 하는데 요청을 가로채는 과정에서 500이 뜨던 버그가 있어 수정했습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 내부 경로가 아니면 HandlerMethod가 아닌 handler이 올 수도 있다는 것을 새롭게 알게 되었네요. 기존에 swagger-ui 경로에 접근하지 못하던 문제도 이걸로 처리할 수 있었겠네요 |
||
HandlerMethod handlerMethod = (HandlerMethod) handler; | ||
|
||
Auth classAnnotation = handlerMethod.getClass().getAnnotation(Auth.class); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package hyundai.softeer.orange.event.fcfs.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ResponseFcfsInfoDto { | ||
|
||
private LocalDateTime nowDateTime; | ||
|
||
private String eventStatus; | ||
} |
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.
파편화된 Key 문자열과 매직넘버를 상수로 관리하고자 했습니다.
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.
좋은 것 같습니다. 저도 여기에다 admin 부분을 등록해서 변경해둬야겠네요