-
Notifications
You must be signed in to change notification settings - Fork 12
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] 김경규 강화하기 #8
base: koungq
Are you sure you want to change the base?
Conversation
import static leets.enhance.domain.item.entity.Status.*; | ||
|
||
@Entity | ||
@Table(name = "item") |
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.
굳이 안써도 될 어노테이션이었네요 놓친 부분 감사합니다 👍
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 enum SuccessProbability { | ||
|
||
MIN(0, 0.9), // 파괴됐을 경우 | ||
LEVEL_1(1, 0.9), | ||
LEVEL_2(2, 0.8), | ||
LEVEL_3(3, 0.7), | ||
LEVEL_4(4, 0.5), | ||
LEVEL_5(5, 0.3), | ||
LEVEL_6(6, 0.1), | ||
MAX(7, 0.03); | ||
|
||
private final int currentLevel; | ||
private final double probability; | ||
|
||
SuccessProbability(int currentLevel, double probability) { | ||
this.currentLevel = currentLevel; | ||
this.probability = probability; | ||
} | ||
|
||
public static double getProbability(int level) { | ||
return Arrays.stream(values()) | ||
.filter(probability -> probability.getCurrentLevel() == level) | ||
.map(SuccessProbability::getProbability) | ||
.findAny() | ||
.orElse(MAX.probability); | ||
} |
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.
하나의 레벨 enum으로 파괴확률과 성공확률을 관리하는건 어떨까요? 성공과 파괴는 상태이지 하나의 객체로 보기는 어렵다는 생각이 듭니다 어떻게 생각하시나요?
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.
하나의 Probability로 처리하는게 더 좋아보이긴 하네요 감사합니당 👍
|
||
public Item getItem(Long itemId) { | ||
return itemRepository.findById(itemId) | ||
.orElseThrow(() -> new InvalidAccessException(INVALID_ITEM)); |
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.
커스텀 한거에요 👍
@PrePersist | ||
public void init() { | ||
this.booster = 3; | ||
} |
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.
감사합니다 👍
No description provided.