-
Notifications
You must be signed in to change notification settings - Fork 2
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
[BE] refactor: 세션을 가져오는 역할을 ReviewGroupSessionResolver
에 위임
#843
Merged
+269
−283
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c3adcad
refactor: 사용하지 않는 클래스 제거
donghoony ae1edbf
feat: 세션에서 리뷰 그룹 resolve
donghoony ee36397
refactor: `Resolver` `@MockBean` 등록
donghoony f06edf6
refactor: `CorsConfig` Disable 처리
donghoony 04a459b
feat: `Resolver`를 사용해 리뷰 그룹을 가져오도록 구현
donghoony b23d810
chore: 사용하지 않는 `ReviewGroupRepository` 필드 제거
donghoony dc9797b
refactor: 서비스 메서드 추가 및 `ServiceTest` 제거
donghoony 3ba4822
fix: `ReviewGroupService` mockbean 처리
donghoony 980649c
chore: -요 체로 변경
donghoony File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
package reviewme.config; | ||
|
||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
import reviewme.global.HeaderPropertyArgumentResolver; | ||
import reviewme.reviewgroup.controller.ReviewGroupSessionResolver; | ||
import reviewme.reviewgroup.service.ReviewGroupService; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
public class WebConfig implements WebMvcConfigurer { | ||
|
||
private final ReviewGroupService reviewGroupService; | ||
|
||
@Override | ||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) { | ||
resolvers.add(new HeaderPropertyArgumentResolver()); | ||
resolvers.add(new ReviewGroupSessionResolver(reviewGroupService)); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
backend/src/main/java/reviewme/global/HeaderPropertyArgumentResolver.java
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
backend/src/main/java/reviewme/global/exception/MissingHeaderPropertyException.java
This file was deleted.
Oops, something went wrong.
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
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
11 changes: 11 additions & 0 deletions
11
backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupSession.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,11 @@ | ||
package reviewme.reviewgroup.controller; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.PARAMETER) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface ReviewGroupSession { | ||
} |
12 changes: 12 additions & 0 deletions
12
...nd/src/main/java/reviewme/reviewgroup/controller/ReviewGroupSessionNotFoundException.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,12 @@ | ||
package reviewme.reviewgroup.controller; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import reviewme.global.exception.BadRequestException; | ||
|
||
@Slf4j | ||
public class ReviewGroupSessionNotFoundException extends BadRequestException { | ||
|
||
public ReviewGroupSessionNotFoundException() { | ||
super("리뷰 그룹 세션이 존재하지 않아요."); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupSessionResolver.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,42 @@ | ||
package reviewme.reviewgroup.controller; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpSession; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.core.MethodParameter; | ||
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; | ||
import reviewme.reviewgroup.domain.ReviewGroup; | ||
import reviewme.reviewgroup.service.ReviewGroupService; | ||
|
||
@RequiredArgsConstructor | ||
public class ReviewGroupSessionResolver implements HandlerMethodArgumentResolver { | ||
|
||
private static final String SESSION_KEY = "reviewRequestCode"; | ||
|
||
private final ReviewGroupService reviewGroupService; | ||
|
||
@Override | ||
public boolean supportsParameter(MethodParameter parameter) { | ||
return parameter.hasParameterAnnotation(ReviewGroupSession.class); | ||
} | ||
|
||
@Override | ||
public ReviewGroup resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, | ||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { | ||
HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class); | ||
HttpSession session = request.getSession(false); | ||
|
||
// 세션이 없거나, 세션 안에 reviewRequestCode가 존재하지 않는 경우 | ||
if (session == null) { | ||
throw new ReviewGroupSessionNotFoundException(); | ||
} | ||
String reviewRequestCode = (String) session.getAttribute(SESSION_KEY); | ||
if (reviewRequestCode == null) { | ||
throw new ReviewGroupSessionNotFoundException(); | ||
} | ||
return reviewGroupService.getReviewGroupByReviewRequestCode(reviewRequestCode); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
의견)
패키지 위치는 지금처럼 reviewGroup.controller가 적절하다고 생각해요.
컨트롤러
로 들어오고 → 해당하는 부분 처리를리졸버
로 보냈다가 →컨트롤러
로 다시 받아서 다음 처리를 한다.위처럼 컨트롤러의 처리 사이에서만 쓰이기때문이죠!