-
Notifications
You must be signed in to change notification settings - Fork 3
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
The head ref may contain hidden characters: "be/feat/#158-be-\uBB34\uB4DC-\uC870\uD68C-api-\uAD6C\uD604"
Conversation
- 성공 케이스인데 실패 케이스처럼 보여서 추가했습니다
- 무드는 회원가입시 필요하므로 whitelist에 포함되어야 합니다
- 400 -> 401, 404
- 단위테스트를 위해 분리하였습니다
|
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.
👍
@@ -1,6 +1,6 @@ | |||
package com.foodymoody.be.common.exception; | |||
|
|||
public class IncorrectMemberPasswordException extends BusinessException { | |||
public class IncorrectMemberPasswordException extends UnauthorizedException { |
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.
Exception -> RuntimeException -> BusinessException -> UnauthorizedException -> IncorrectMemberPasswordException
deep가 너무 깊어서 추천하지 않아요.~ 원인은 한번 확인 해봐요.
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.
부모 클래스가 많을수록 클래스가 복잡해지고, 불필요하게 결합도가 높아지는 것 같습니다.. 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)) { |
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.
이제 password 암호화를 고민 해봐도 좋을 것 같아요.예를 들어 jasypt
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.
단방향 암호화 추가하겠습니다!
@Query(value = "SELECT * FROM mood ORDER BY rand() LIMIT :count", nativeQuery = true) | ||
List<Mood> findRandom(int count); | ||
|
||
boolean existsByName(String mood); |
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.
mood 보다 name가 더 적합하지 않을 까요 ?
List<MoodResponse> moodResponses = moods.stream() | ||
.map(MoodMapper::toResponse) | ||
.collect(Collectors.toUnmodifiableList()); | ||
return MoodMapper.toRandomResponse(moodResponses); |
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.
public RandomMoodResponse findRandom(int count) {
List<Mood> moods = moodRepository.findRandom(count);
return MoodMapper.toRandomResponse(moods);
}
로 수정하겠습니다!
- WrappedId로 수정
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)
테스트할 때 있으면 좋을 것 같아서 위 코드들을 추가했습니다.
To reviewer👋