-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat/replace enum with type entity] - Enum 을 Type Entity로 교체 #67
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
293a07d
:recycle: refactor : reformat code
ekgns33 32654aa
:sparkles: feat : create `EggType` entity
ekgns33 23f9f71
:sparkles: feat : update `EggType` field from enum to entity; relate …
ekgns33 88e5e50
:sparkles: feat : replace enum to `EggType` entity
ekgns33 4a004e9
:recycle: refactor : use egg-code instead of type
ekgns33 e829e1a
:recycle: refactor : use `GREETING_EGG_ID` for creating Greeting Egg
ekgns33 8bf87a8
:hammer: chore : update ddl, dml scripts
ekgns33 22359a8
:white_check_mark: test : update test code
ekgns33 eddf453
:recycle: refactor : change jpql to data jpa function
ekgns33 bf70c20
:recycle: refactor : refactor collecting runimoTypeInfo
ekgns33 e8e3b10
:recycle: refactor : rename parameter from `eggLevel` to `level`
ekgns33 f66deb1
:bug: fix : fix relation from `@OneToOne` to `@ManyToOne`
ekgns33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/org/runimo/runimo/hatch/service/usecase/HatchUsecaseImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,55 @@ | ||
| package org.runimo.runimo.item.domain; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import static org.runimo.runimo.common.GlobalConsts.EMPTYFIELD; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import org.runimo.runimo.common.BaseEntity; | ||
|
|
||
| @Table(name = "egg_type") | ||
| @Entity | ||
| @Getter | ||
| public enum EggType { | ||
| MADANG("A100", "마당", 0L), | ||
| FOREST("A101", "숲", 30000L), | ||
| // GRASSLAND("A102", "초원", 50000L), | ||
| ; | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class EggType extends BaseEntity { | ||
|
|
||
| private final String code; | ||
| private final String name; | ||
| private final Long requiredDistanceInMeters; | ||
| public static final EggType EMPTY = new EggType(EMPTYFIELD, EMPTYFIELD, 0L, 0); | ||
|
|
||
| @Column(name = "name", nullable = false) | ||
| private String name; | ||
| @Column(name = "code", nullable = false) | ||
| private String code; | ||
| @Column(name = "required_distance_in_meters", nullable = false) | ||
| private Long requiredDistanceInMeters; | ||
| @Column(name = "level", nullable = false) | ||
| private Integer level; | ||
|
|
||
| EggType(String code, String name, Long requiredDistanceInMeters) { | ||
| this.code = code; | ||
| @Builder | ||
| private EggType(String name, String code, Long requiredDistanceInMeters, Integer level) { | ||
| this.name = name; | ||
| this.code = code; | ||
| if (requiredDistanceInMeters < 0) { | ||
| throw new IllegalArgumentException("알의 요구 거리(미터)는 0보다 작을 수 없습니다."); | ||
| } | ||
| this.requiredDistanceInMeters = requiredDistanceInMeters; | ||
| if (level < 0) { | ||
| throw new IllegalArgumentException("알의 레벨은 0보다 작을 수 없습니다."); | ||
| } | ||
| this.level = level; | ||
| } | ||
|
|
||
| public static List<EggType> getUnLockedEggTypes(final Long distance) { | ||
| return Arrays.stream(EggType.values()) | ||
| .filter(type -> type.requiredDistanceInMeters < distance) | ||
| .toList(); | ||
| public static EggType of(String name, String code, Long requiredDistanceInMeters, | ||
| Integer level) { | ||
| return EggType.builder() | ||
| .name(name) | ||
| .code(code) | ||
| .requiredDistanceInMeters(requiredDistanceInMeters) | ||
| .level(level) | ||
| .build(); | ||
| } | ||
|
|
||
| } |
14 changes: 14 additions & 0 deletions
14
src/main/java/org/runimo/runimo/item/repository/EggTypeRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package org.runimo.runimo.item.repository; | ||
|
|
||
| import java.util.List; | ||
| import org.runimo.runimo.item.domain.EggType; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface EggTypeRepository extends JpaRepository<EggType, Long> { | ||
|
|
||
| List<EggType> findAllByOrderByIdAsc(); | ||
|
|
||
| List<EggType> findEggTypeByRequiredDistanceInMetersLessThanEqual(Long totalDistanceInMeters); | ||
|
|
||
| List<EggType> findEggTypeByLevelLessThan(Integer level); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/main/java/org/runimo/runimo/rewards/service/dto/RewardResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.