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

be/feat/#158 be 무드 조회 api 구현 #160

Merged
merged 20 commits into from
Nov 16, 2023

Conversation

sejeongsong
Copy link
Collaborator

@sejeongsong sejeongsong commented Nov 14, 2023

Key changes🔧

  • be/src/test/java/com/foodymoody/be/acceptance/util/TableCleanup.java
    테이블의 이름을 지정해서 특정 테이블을 truncate 할 수 있는 util 클래스입니다.
  • be/src/test/java/com/foodymoody/be/acceptance/util/SqlFileExecutor.java
    .sql 확장자의 파일을 실행해주는 util 클래스입니다.
    sql 파일의 resources를 루트로 하는 상대경로나, 절대경로를 지정해서 사용합니다.
  • be/src/test/java/com/foodymoody/be/acceptance/AccptanceTest.java
    protected void 데이터베이스를_비운다()
    protected void 데이터베이스를_초기화한다()
    protected void sql파일을_실행한다(String sqlFilePath)
    protected void 테이블을_비운다(String tableName)
  • be/src/test/java/com/foodymoody/be/acceptance/util/DatabaseCleanup.java
    public void setExcludeTables(List<String> excludeTables)

테스트할 때 있으면 좋을 것 같아서 위 코드들을 추가했습니다.

  1. BusinessException에서 getCode()가 message를 반환하는 버그를 수정했습니다.
  2. 상태코드 401을 반환하는 UnauthorizedException, 상태코드 404를 반환하는 GlobalNotFoundException을 추가했습니다.

To reviewer👋

@AlbertImKr
Copy link

be/src/test/java/com/foodymoody/be/acceptance/util/TableCleanup.java
be/src/test/java/com/foodymoody/be/acceptance/util/SqlFileExecutor.java
AccptanceTest에 protected void 데이터베이스를_비운다() , protected void 데이터베이스를_초기화한다() , protected void sql파일을_실행한다(String sqlFilePath), protected void 테이블을_비운다(String tableName) 메서드 추가
DatabaseCleanup에 public void setExcludeTables(List excludeTables) 메서드 추가
가독성이 떨어지는 것 같아요. 기능 설명을 하면 좋을 것 같아요.

Copy link

@AlbertImKr AlbertImKr left a comment

Choose a reason for hiding this comment

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

👍

@@ -1,6 +1,6 @@
package com.foodymoody.be.common.exception;

public class IncorrectMemberPasswordException extends BusinessException {
public class IncorrectMemberPasswordException extends UnauthorizedException {

Choose a reason for hiding this comment

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

Exception -> RuntimeException -> BusinessException -> UnauthorizedException -> IncorrectMemberPasswordException
deep가 너무 깊어서 추천하지 않아요.~ 원인은 한번 확인 해봐요.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

부모 클래스가 많을수록 클래스가 복잡해지고, 불필요하게 결합도가 높아지는 것 같습니다.. BusinessException을 상속받지 않도록 수정하겠습니다!

@@ -57,7 +57,7 @@ public String getMoodId() {
}

public void validatePassword(String password) {
if (Objects.isNull(password)) {
if (Objects.isNull(password) || !Objects.equals(password, this.password)) {

Choose a reason for hiding this comment

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

이제 password 암호화를 고민 해봐도 좋을 것 같아요.예를 들어 jasypt

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

단방향 암호화 추가하겠습니다!

@Query(value = "SELECT * FROM mood ORDER BY rand() LIMIT :count", nativeQuery = true)
List<Mood> findRandom(int count);

boolean existsByName(String mood);

Choose a reason for hiding this comment

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

mood 보다 name가 더 적합하지 않을 까요 ?

Comment on lines 43 to 46
List<MoodResponse> moodResponses = moods.stream()
.map(MoodMapper::toResponse)
.collect(Collectors.toUnmodifiableList());
return MoodMapper.toRandomResponse(moodResponses);

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.

    public RandomMoodResponse findRandom(int count) {
        List<Mood> moods = moodRepository.findRandom(count);
        return MoodMapper.toRandomResponse(moods);
    }

로 수정하겠습니다!

@sejeongsong sejeongsong merged commit 59ce448 into dev-be Nov 16, 2023
2 checks passed
@sejeongsong sejeongsong deleted the be/feat/#158-be-무드-조회-api-구현 branch November 20, 2023 09:00
@sejeongsong sejeongsong linked an issue Nov 20, 2023 that may be closed by this pull request
1 task
@sejeongsong sejeongsong changed the title Be/feat/#158 be 무드 조회 api 구현 be/feat/#158 be 무드 조회 api 구현 Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[BE] 무드 조회 API 구현
2 participants