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

[Team-20 / BE - Dong] 숙소 조회, 좋아요를 누른 숙소 기능 #53

Open
wants to merge 85 commits into
base: team-20
Choose a base branch
from

Conversation

moto6
Copy link
Collaborator

@moto6 moto6 commented May 28, 2021

intro

안녕하세요 Team-20 BE Dong 입니다

지금 많은 부분이 부족한 코드인데 조금은 마음이 싱숭생숭해서 부족한 코드지만PR 날립니다 😥😥😥😥😥

Done

  • 숙소 정보 리스트
  • 좋아요 누른 숙소만 리턴해주는 기능
  • 메인페이지에서 추천여행지, 테마숙소 리턴해주는 기능

Todo(앞으로 진행할것들)

  • 배포 자동화
  • 테스트코드

궁금한점

  • 입력받는 부분에서 검색조건을 받아서 조건에 맞는 숙소를 돌려줘야하는데, 데이터베이스 where절로 처리해야할지, 자바코드로 if 문을 활용해야 할지 고민입니다
  • recursive query 기능을 이용해서 "서울시" 를 검색하면, 서울시의 하위 행정구역인 "서초구", "강남구" 등을 검색할수 있는 쿼리문을 구현했는데, 이를 프로젝트에 실제로 어떻게 적용해야할지 모르겠습니다.

moto6 and others added 30 commits May 17, 2021 17:18
[BE] Dto 멤버 내용 추가
필드변수로    private String accessToken;
          private String tokenType;
          private String scope;
가 있음
- 클래스 및 생성자와 구현을 위한 메서드 껍데기만 만듬
- 데이터가 포함된 로직은 아직 구현 안됨
- 생성자 수정
- 컨트롤러에 getSample() 메서드 추가
- AccommodationDTO 필드변수 도메인과 동일하게 수정
@wheejuni wheejuni self-assigned this May 30, 2021
Copy link

@wheejuni wheejuni left a comment

Choose a reason for hiding this comment

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

데이터베이스에 질의하는 로직을 if로 처리하면, 나중에 데이터가 방대해져서 페이징 등이 발생할 때 어떻게 대처할지도 잘 고민해 보셔야 할 겁니다. 개인적으로 추천하는 방식은 아닙니다.

"행정구역" 에 관한 개념이 추상화되어 있으면 되겠죠? 서로간의 포함관계가 존재하면 될 겁니다.

그런데 지금 그런 부분보다도, "관성적으로 코딩하지 않는 방법" 에 대한 고민이 필요한 시점이라고 판단됩니다.
그런 고민이 부족하신 듯 보여서 조금 아쉽다는 느낌은 들었습니다. 여튼 수고 많으셨고 수정해야 할 부분에 대해 다시 살펴보셨으면 좋겠습니다. 💯

Comment on lines 23 to 28
private final String GITHUB_ACCESS_TOKEN_URI = "https://github.com/login/oauth/access_token";
private final String GITHUB_USER_URI = "https://api.github.com/user";
private final String ISSUER = "";
private final String CLIENT_ID = "your client id";
private final String CLIENT_SECRET = "your client secret";
private final String CODE = "";

Choose a reason for hiding this comment

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

컨트롤러에 위치해야 할 정보들이 아닌 것 같습니다. 어떻게 분리할 수 있을까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

제가 너무 안일한 생각을 했습니다.

아주아주 간단한 모듈(auth)이 라서, 서비스계층과 컨트롤러 계층을 나눌 생각을 하지 않았는데, 말씀을 듣고 나니 컨트롤러 계층에서 가지고 있기 부적절한 정보가 맞습니다. 수정 완료했습니다!

Comment on lines 43 to 44
System.out.println(accessToken);
System.out.println(gitHubRequest);

Choose a reason for hiding this comment

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

안됩니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 수정했습니다!

Comment on lines 68 to 91
private Optional<User> getUserFromGitHub(GithubAccessTokenResponse accessToken, RestTemplate gitHubRequest) {
RequestEntity<Void> request = RequestEntity
.get(GITHUB_USER_URI)
.header("Accept", "application/json")
.header("Authorization", "token " + accessToken.getAccessToken())
.build();

ResponseEntity<User> response = gitHubRequest
.exchange(request, User.class);

return Optional.ofNullable(response.getBody());
}

private Optional<GithubAccessTokenResponse> getAccessToken(String code, RestTemplate gitHubRequest) {
RequestEntity<GithubAccessTokenRequest> request = RequestEntity
.post(GITHUB_ACCESS_TOKEN_URI)
.header("Accept", "application/json")
.body(new GithubAccessTokenRequest(CLIENT_ID, CLIENT_SECRET, code));

ResponseEntity<GithubAccessTokenResponse> response = gitHubRequest
.exchange(request, GithubAccessTokenResponse.class);

return Optional.ofNullable(response.getBody());
}

Choose a reason for hiding this comment

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

별도의 서비스나 클라이언트 클래스(컴포넌트 클래스) 가 구성돼야 하겠지요?
컨트롤러에 있으면 안될 녀석들인 것 같은데 어떻게 생각하시는지 궁금합니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

네 위에서 말씀해주셔서 해당 부분은 코드에 반영했습니다

.sign(algorithm);
} catch (JWTCreationException exception) {
//Invalid Signing configuration / Couldn't convert Claims.
throw new RuntimeException(exception);

Choose a reason for hiding this comment

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

JWTCreationException 이라는 라이브러리에서 제공하는 checked exception을 그냥 RuntimeException 으로 던지네요?
좋은 예외처리일까요? 어떻게 생각하시나요? RuntimeException 으로 충분한가요?

Comment on lines 56 to 60
return JWT.create()
.withClaim("login", user.getLogin())
.withClaim("name", user.getName())
.withIssuer(ISSUER)
.sign(algorithm);

Choose a reason for hiding this comment

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

마찬가지로 별도의 컴포넌트 구성돼야 하겠죠?

package com.example.airbnb.exception;

public class JWTCreationException extends RuntimeException {
final static String MESSAGE = "error";

Choose a reason for hiding this comment

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

우선 이 상수를 이 클래스에서 관리해야겠다고 생각한 이유가 궁금합니다.
그리고 MESSAGE 라는 변수명이 어떠한 의미를 갖는지가 궁금하군요.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

앗 해당부분은 제가 놓쳤네요. 조금 더 명확한 문자열의 이름과 메시지를 작성하였습니다!

Comment on lines 19 to 20
private JdbcTemplate jdbcTemplate;
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;

Choose a reason for hiding this comment

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

이 두 컴포넌트 다 주입받을 수 있을 겁니다.
Spring Context에서 어떤 컴포넌트를 기본으로 빈 등록해서 주입해줄 수 있는지 알아보시는 것도 큰 도움이 되겠네요.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 리뷰해주신 부분 동의합니다!

Comment on lines 38 to 46
private boolean isPeopleCountValidated(SearchConditions conditions) {
if (0 >= conditions.getAdults()) {
return false;
}
if (0 >= conditions.getChildren()) {
return false;
}
return 0 < conditions.getInfants();
}

Choose a reason for hiding this comment

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

SearchConditions 로 이동시키면 어떨까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 해당부분 코드 수정했습니다!

private static final List<RecommendedDTO> recommendedDTOList = new ArrayList<>();
private static final List<ThemeDTO> themeDTOList = new ArrayList<>();

static {

Choose a reason for hiding this comment

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

DB에 미리 넣어두는 방식은 안되려나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

음 지금은 해당 Recommended, Theme 정보가 추가되거나 삭제되지 않는 형태라서 아직 DB 는 아니지만, 장기적인 관점에서는 확장성을 위해서 DB 에 넣어주는 방식이 좋을꺼같습니다!

moto6 added 24 commits June 1, 2021 13:21
- reviewCount가 정상적으로 실행되지 않고 null 값이 나오던 문제를 수정
- Options 필드 추가
- fe 측 요청으로 location 관련한 컬럼 데이터 추가
- 단순한 String class의 래핑클래스이므로 삭제
crongro pushed a commit that referenced this pull request Jun 7, 2021
[FE]라우터 link reload 오류 해결
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants