Skip to content
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

켈리 1-6 단계 제출 #8

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

kelly6bf
Copy link

No description provided.

kelly6bf and others added 15 commits April 18, 2024 17:20
* feat: Welcome Page 생성

* feat: /admin/index Page 수정 및 라우팅 설정
/admin/index Page의 Bootstrap 의존성을 제거함.
/admin/index의 GET 라우팅을 설정함.

* feat: 예약 데이터 조회 기능 구현

* feat: 예약 추가 및 삭제 기능 구현

* refactor: html 경로 정정

* refactor: repository 클래스 리팩터링

* refactor: controller 클래스 리팩터링

* docs: README.md 추가

* refactor: ReservationEntity -> Reservation 변경

* refactor: Reservation 불필요한 정적 팩터리 메서드를 생성자로 변경

* refactor: ReservationRepository 불필요한 final 키워드 제거

* refactor: SaveReservationRequest 메서드명 변경
SaveReservationRequest의 toEntity 메서드명을 toReservation으로 변경함

* refactor: AdminApiController ResponseEntity 제거

* refactor: ReservationDto -> ReservationResponse 클래스명 변경

* test: Reservation 클래스 테스트 로직 작성

* test: MemoryReservationRepository 테스트 코드 작성

* test: SaveReservationRequest 테스트 로직 작성

* refactor: MemoryReservationRepository 자료구조와 인덱스값을 멤버 변수로 변경

* test: MemoryReservationRepositoryTest 정정

* test: MemoryReservationRepositoryTest 불필요한 어노테이션 제거

* test: AdminApiControllerTest 테스트 단위 분리

* test: ReservationResponse 테스트 로직 작성

---------

Co-authored-by: MingyeomKim <[email protected]>
기존 Reservation의 LocalDateTime 변수를 LocalDate와 LocalTime으로 분리함.
h2 데이터베이스를 기반으로 예약 데이터를 처리하는 Repository를 구현함.
Copy link
Member

@seokmyungham seokmyungham left a comment

Choose a reason for hiding this comment

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

켈뤼~ 전체적으로 꼼꼼하게 잘 작성했네요 👍
미션 마지막까지 화이팅 해봅시다

- [X] 어드민 페이지 조회
- [X] 예약 페이지 조회

# API
Copy link
Member

Choose a reason for hiding this comment

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

켈리~
resource 마다 request, response 명세를 적어주면 더 좋을 것 같네요 👍

@@ -0,0 +1,22 @@
package roomescape.domain;

public class ClientName {
Copy link
Member

Choose a reason for hiding this comment

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

1단계에서 학습한 부분을 잊지 않았군요. 꼼꼼하게 원시 값을 포장했네요 👍

Comment on lines +27 to +30
private void validateReservationDateAndTime(final LocalDate date, final LocalTime time) {
LocalDateTime reservationLocalDateTime = LocalDateTime.of(date, time);
if (reservationLocalDateTime.isBefore(LocalDateTime.now())) {
throw new IllegalArgumentException("현재 날짜보다 이전 날짜를 예약할 수 없습니다.");
Copy link
Member

Choose a reason for hiding this comment

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

오~ 이건 진짜 잘했는데요? 👍👍
베워갑니다

this.template = template;
}

@Bean
Copy link
Member

Choose a reason for hiding this comment

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

@component 대신 @bean을 직접 등록한 이유가 있나요??
설명해주세요~

Copy link
Member

Choose a reason for hiding this comment

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

저도 궁금해요
기준이 있다면 pr description이나 readme에 적어주는 것은 어떨까요?!

</head>
<body>
<h1>Kelly & Anna Welcome Page!</h1>
<p>Spring 너무 어렵다...</p>
Copy link
Member

Choose a reason for hiding this comment

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

동의합니다..🙃

import java.time.LocalDate;
import java.time.LocalTime;

public record ReservationResponse(Long id, String name, LocalDate date, LocalTime time) {
Copy link
Member

Choose a reason for hiding this comment

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

클라이언트 http 응답을 null을 주지는 않을 것 같은데 Long을 사용하신 이유가 있을까용

}

@DeleteMapping("/reservations/{reservation-id}")
public void deleteReservation(@PathVariable("reservation-id") final Long reservationId) {
Copy link
Member

Choose a reason for hiding this comment

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

여기도 pathvariable value를 null을 받고 싶은 의도가 있으신건가요?


long savedReservationId = keyHolder.getKey().longValue();

return reservation.initializeIndex(savedReservationId);
Copy link
Member

Choose a reason for hiding this comment

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

오호 이렇게도 할 수 있군요 👍
배워갑니다

}

@Override
public void deleteById(final Long reservationId) {
Copy link
Member

Choose a reason for hiding this comment

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

이 기능도 내부적으로 null을 필요로하는게 아니면 long이 옳다고 생각합니다. (내부 동작과 시그니처의 일관성)

import java.time.LocalTime;

public class Reservation {
private static final Long DEFAULT_ID_VALUE = 0L;
Copy link
Member

Choose a reason for hiding this comment

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

이렇게 기본 값을 명시하면 어떤 점이 좋은지 궁금해요

Copy link
Member

@hyxrxn hyxrxn left a comment

Choose a reason for hiding this comment

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

잘 읽었습니다!
file changed가 많아서 약간 당황했네요... ㅋㅋㅋㅋ
남은 미션도 화이팅 하십쇼~~

@@ -13,12 +13,23 @@ repositories {
}

dependencies {
Copy link
Member

Choose a reason for hiding this comment

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

주석을 달아두니 보기 좋군요

this.template = template;
}

@Bean
Copy link
Member

Choose a reason for hiding this comment

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

저도 궁금해요
기준이 있다면 pr description이나 readme에 적어주는 것은 어떨까요?!


@Controller
public class AdminWebController {

Copy link
Member

Choose a reason for hiding this comment

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

클래스 선언 이후 공백 줄이 대부분 없는 것으로 보이는데,
혹시 공백 없이 바로 메서드나 필드를 쓰는 것이 본인의 컨벤션이라면 이 줄은 지우는게 좋겠네요~


private void validateReservationDateAndTime(final LocalDate date, final LocalTime time) {
LocalDateTime reservationLocalDateTime = LocalDateTime.of(date, time);
if (reservationLocalDateTime.isBefore(LocalDateTime.now())) {
Copy link
Member

Choose a reason for hiding this comment

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

이런 메소드가 있는 걸 처음 알았네요
이것도 예약자 이름 길이 검증처럼 readme에 함께 작성해주면 어떨까요?
코드 읽기 전 실행 먼저 해봤다가 예약 안되는줄...

import java.util.List;

@RestController
public class AdminApiController {
Copy link
Member

Choose a reason for hiding this comment

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

이렇게 이름을 정한 이유는 현재 api가 reservation 관련 하나만 있어서인가요?
time 관련 api가 추가되고 이름을 어떻게 바꿨는지도 궁금하네요!


import java.util.List;

public interface ReservationRepository {
Copy link
Member

Choose a reason for hiding this comment

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

인터페이스로 분리해둔 이유를 듣고 싶어요


@BeforeEach
public void initReservation() {
RestAssured.port = randomServerPort;
Copy link
Member

Choose a reason for hiding this comment

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

이런 방법이 있군요...!


@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD)
class AdminApiControllerTest {
Copy link
Member

Choose a reason for hiding this comment

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

api 명세를 따르는게 우선이라고 생각해서 코드를 모두 200으로 그대로 둔건가요?

Comment on lines +3 to +14
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import roomescape.domain.Reservation;
import roomescape.dto.ReservationResponse;
import roomescape.dto.SaveReservationRequest;
import roomescape.repository.ReservationRepository;

import java.util.List;
Copy link
Member

Choose a reason for hiding this comment

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

구글 자바 컨벤션에서 non-static import는 빈 줄 없이 한 블록으로 구분되어야 할 거에요~~~
참고 하세용


@ExceptionHandler
protected ResponseEntity<ErrorResponse> handleIllegalArgumentException(IllegalArgumentException e) {
return ResponseEntity.badRequest().body(new ErrorResponse(e.getMessage()));
Copy link
Member

Choose a reason for hiding this comment

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

요렇게 전달하면 어디서 어떻게 처리가 되나요???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants