Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2abbfa0
feature: Handler 어노테이션 추가
devjun10 Feb 19, 2024
afb76b7
refactor: 빈 등록/빈 조회 메서드 추가
devjun10 Feb 19, 2024
98e6bc9
feature: 사용자 정보 업데이트 기능 개발
devjun10 Feb 19, 2024
fecc578
refactor: Path 명시
devjun10 Feb 19, 2024
18841b9
refactor: Http setAttribute 기능 추가
devjun10 Feb 19, 2024
3afbe3a
refactor: DispatcherServlet 빈 초기화 방식 변경
devjun10 Feb 19, 2024
fb5b15b
refactor: 세션 로직 변경
devjun10 Feb 20, 2024
be7ed0a
refactor: 에러 응답
devjun10 Feb 19, 2024
c0c7c64
chore: task 의존성 변경
devjun10 Mar 26, 2024
2956fb8
docs: README.md 업데이트
devjun10 Mar 26, 2024
023b4b5
refactor: 인터셉터 경로 추가
devjun10 Mar 26, 2024
424e277
feat: Application/Json 타입 사용자 정보 업데이트 API 개발
devjun10 Mar 26, 2024
fcef502
refactor: 로그인 컨트롤러 log 제거
devjun10 Mar 26, 2024
49547fa
test: @AfterEach -> @BeforeEach로 변경
devjun10 Mar 26, 2024
4350b67
feat: Application/Json을 처리하기 위한 어노테이션 추가
devjun10 Mar 26, 2024
045c610
feat: 임시 커밋 추가
devjun10 Mar 26, 2024
53aa75f
refactor: 기본 포트 8080으로 변환
devjun10 Mar 26, 2024
947a8c7
docs: README.md 내용 추가
devjun10 Mar 26, 2024
eb19568
test: 깨진 테스트 복구
devjun10 Mar 26, 2024
9959627
refactor: CheckStyle, PMD 설정 적용
devjun10 Mar 26, 2024
8b65cdb
docs: README.md 내용 추가
devjun10 Mar 26, 2024
fec3b99
refactor: 미 반영사항 적용
devjun10 Apr 2, 2024
4313365
chore: schema 추가
devjun10 Apr 7, 2024
c38b3d4
docs: README.md 내용 추가
devjun10 Apr 7, 2024
a00907a
refactor: 일급 컬렉션에서 쿠키를 추출하도록 로직 변경
devjun10 May 10, 2024
1fccab2
docs: README.md 수정
devjun10 Jun 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package project.server.app.core.web.user.presentation;

import project.server.mvc.servlet.HttpServletRequest;
import project.server.mvc.servlet.HttpServletResponse;
import project.server.mvc.springframework.annotation.Controller;
import project.server.mvc.springframework.annotation.GetMapping;
import project.server.mvc.springframework.web.servlet.Handler;
import project.server.mvc.servlet.HttpServletRequest;
import project.server.mvc.servlet.HttpServletResponse;
import project.server.mvc.springframework.web.servlet.ModelAndView;

@Controller
public class HomeController implements Handler {

@Override
@GetMapping("/")
@GetMapping(path = "/")
public ModelAndView process(
HttpServletRequest request,
HttpServletResponse response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import project.server.mvc.servlet.http.Cookie;
import static project.server.mvc.servlet.http.HttpStatus.MOVE_PERMANENTLY;
import project.server.mvc.springframework.annotation.Controller;
import project.server.mvc.springframework.annotation.PostMapping;
import project.server.mvc.springframework.web.servlet.Handler;
import project.server.mvc.springframework.web.servlet.ModelAndView;

Expand All @@ -30,12 +31,13 @@ public LoginController(
}

@Override
@PostMapping(path = "/sign-in")
public ModelAndView process(
HttpServletRequest request,
HttpServletResponse response
) {
String username = request.getAttribute("username");
String password = request.getAttribute("password");
String username = (String) request.getAttribute("username");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

이렇게 리팩토링 하신 이유가 있나요?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

인터셉터를 별도로 생성해, 중복되는 로직을 모두 삭제했습니다.

String password = (String) request.getAttribute("password");
log.info("username: {}, password: {}", username, password);

validator.validateLoginInfo(username, password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

getAttribute의 반환값이 Object로 되어있는데 String이 아닌 경우는 어떤 경우죠?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import project.server.mvc.servlet.HttpServletResponse;
import static project.server.mvc.servlet.http.HttpStatus.NO_CONTENT;
import project.server.mvc.springframework.annotation.Controller;
import project.server.mvc.springframework.annotation.DeleteMapping;
import project.server.mvc.springframework.web.servlet.Handler;
import project.server.mvc.springframework.web.servlet.ModelAndView;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

path가 바뀐 이유가 궁금합니다!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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);
Expand Down