-
Notifications
You must be signed in to change notification settings - Fork 0
[Step4] 데이터 전송 방식을 일부 변경한다. #5
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
base: dev
Are you sure you want to change the base?
Changes from 1 commit
2abbfa0
afb76b7
98e6bc9
fecc578
18841b9
3afbe3a
fb5b15b
be7ed0a
c0c7c64
2956fb8
023b4b5
424e277
fcef502
49547fa
4350b67
045c610
53aa75f
947a8c7
eb19568
9959627
8b65cdb
fec3b99
4313365
c38b3d4
a00907a
1fccab2
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 |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| import project.server.mvc.servlet.HttpServletResponse; | ||
| import static project.server.mvc.servlet.http.HttpStatus.OK; | ||
| import project.server.mvc.springframework.annotation.Controller; | ||
| import project.server.mvc.springframework.annotation.PostMapping; | ||
| import project.server.mvc.springframework.annotation.RequestMapping; | ||
| import project.server.mvc.springframework.web.servlet.Handler; | ||
| import project.server.mvc.springframework.web.servlet.ModelAndView; | ||
|
|
@@ -28,12 +29,13 @@ public SignUpController( | |
| } | ||
|
|
||
| @Override | ||
| @PostMapping(path = "/sign-up") | ||
| public ModelAndView process( | ||
| HttpServletRequest request, | ||
| HttpServletResponse response | ||
| ) { | ||
| String username = request.getAttribute("username"); | ||
| String password = request.getAttribute("password"); | ||
| String username = (String) request.getAttribute("username"); | ||
|
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. getAttribute의 반환값이 Object로 되어있는데 String이 아닌 경우는 어떤 경우죠?
Contributor
Author
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. attribute가 꼭 String이 아니더라도, Integer이나 BigDecimal 같은 다른 값이 저장되는 경우에요. 예를 들어, 나이를 파라미터로 받으면 Integer이 들어가겠네요. |
||
| String password = (String) request.getAttribute("password"); | ||
| log.info("username: {}, password: {}", username, password); | ||
|
|
||
| validator.validateLoginInfo(username, password); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,12 +2,8 @@ | |
|
|
||
| import lombok.extern.slf4j.Slf4j; | ||
| import project.server.app.common.login.LoginUser; | ||
| import project.server.app.common.login.Session; | ||
| import static project.server.app.common.utils.HeaderUtils.getSessionId; | ||
| import project.server.app.core.domain.user.User; | ||
| import project.server.app.core.web.user.application.UserLoginUseCase; | ||
| import project.server.app.core.web.user.application.UserSearchUseCase; | ||
| import project.server.app.core.web.user.presentation.validator.UserValidator; | ||
| import project.server.mvc.servlet.HttpServletRequest; | ||
| import project.server.mvc.servlet.HttpServletResponse; | ||
| import static project.server.mvc.servlet.http.HttpStatus.OK; | ||
|
|
@@ -23,34 +19,19 @@ | |
| @RequestMapping("/users") | ||
| public class UserInfoSearchController implements Handler { | ||
|
|
||
| private final UserValidator validator; | ||
| private final UserLoginUseCase loginUseCase; | ||
| private final UserSearchUseCase userSearchUseCase; | ||
|
|
||
| public UserInfoSearchController( | ||
| UserValidator validator, | ||
| UserLoginUseCase loginUseCase, | ||
| UserSearchUseCase userSearchUseCase | ||
| ) { | ||
| this.validator = validator; | ||
| this.loginUseCase = loginUseCase; | ||
| public UserInfoSearchController(UserSearchUseCase userSearchUseCase) { | ||
| this.userSearchUseCase = userSearchUseCase; | ||
| } | ||
|
|
||
| @Override | ||
| @GetMapping(path = "/users/{userId}") | ||
| @GetMapping(path = "/my-info") | ||
|
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. path가 바뀐 이유가 궁금합니다!
Contributor
Author
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. 이 부분은. html과 같게 하려고 경로를 수정했습니다. 처음 설계할 때, 조금 더 신경 써야 했던 것 같습니다. |
||
| public ModelAndView process( | ||
| HttpServletRequest request, | ||
| HttpServletResponse response | ||
| ) { | ||
| Long sessionId = getSessionId(request.getCookies()); | ||
| validator.validateSessionId(sessionId, response); | ||
|
|
||
| Session findSession = loginUseCase.findSessionById(sessionId); | ||
| validator.validateSession(findSession, response); | ||
|
|
||
| log.info("Session:{}", findSession); | ||
| LoginUser loginUser = new LoginUser(findSession); | ||
| LoginUser loginUser = (LoginUser) request.getAttribute("loginUser"); | ||
|
|
||
| User findUser = userSearchUseCase.findById(loginUser.getUserId()); | ||
| ModelMap modelMap = createModelMap(findUser); | ||
|
|
||
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.
인터셉터를 별도로 생성해, 중복되는 로직을 모두 삭제했습니다.