-
Notifications
You must be signed in to change notification settings - Fork 0
[Refactor/runimo domain rename] Runimo 관련 도메인 이름 변경 #30
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
8 commits
Select commit
Hold shift + click to select a range
41b682d
:recycle: refactor : rename Runimo Entity to RunimoDefinition and mod…
jeeheaG 2de5574
:white_check_mark: test : make test for RunimoDefinition refactoring
jeeheaG d125d6e
:recycle: refactor : rename UserRunimo Entity to Runimo
jeeheaG dd3e10c
:white_check_mark: test : make test for Runimo refactoring
jeeheaG 78bff07
:sparkles: add : add column in Runimo (run count, distance)
jeeheaG 27e345d
Merge remote-tracking branch 'origin/main' into refactor/runimo-domai…
jeeheaG 08cfc9c
:recycle: refactor : resolve conflict
jeeheaG c3a9f18
:sparkles: add : add SQL for insert runimo_definition static data
jeeheaG 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
22 changes: 16 additions & 6 deletions
22
src/main/java/org/runimo/runimo/hatch/service/HatchClient.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 |
|---|---|---|
| @@ -1,15 +1,25 @@ | ||
| package org.runimo.runimo.hatch.service; | ||
|
|
||
| import org.runimo.runimo.item.domain.EggType; | ||
| import org.runimo.runimo.runimo.domain.Runimo; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.runimo.runimo.hatch.exception.HatchException; | ||
| import org.runimo.runimo.hatch.exception.HatchHttpResponseCode; | ||
| import org.runimo.runimo.runimo.domain.RunimoDefinition; | ||
| import org.runimo.runimo.runimo.repository.RunimoDefinitionRepository; | ||
| import org.runimo.runimo.user.domain.IncubatingEgg; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| @Service | ||
| public class HatchClient { | ||
| public final RunimoDefinitionRepository runimoDefinitionRepository; | ||
|
|
||
| // TODO : 로직 구현 | ||
| public Runimo getRunimoFromEgg(IncubatingEgg incubatingEgg) { | ||
| return new Runimo("토끼_dummy", "R-100", "마당에 사는 토끼 dummy", "http://dummy", EggType.MADANG); | ||
| public RunimoDefinition getRunimoDefFromEgg(IncubatingEgg incubatingEgg) { | ||
| String dummyRunimoCode = "R-101"; | ||
|
|
||
| RunimoDefinition runimoDefinition = runimoDefinitionRepository.findByCode(dummyRunimoCode) | ||
|
ekgns33 marked this conversation as resolved.
|
||
| .orElseThrow(() -> HatchException.of(HatchHttpResponseCode.HATCH_RUNIMO_NOT_FOUND_INTERNAL_ERROR)); | ||
|
|
||
| return runimoDefinition; | ||
| } | ||
| } | ||
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
44 changes: 25 additions & 19 deletions
44
src/main/java/org/runimo/runimo/runimo/domain/Runimo.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 |
|---|---|---|
| @@ -1,40 +1,46 @@ | ||
| package org.runimo.runimo.runimo.domain; | ||
|
|
||
| import jakarta.persistence.*; | ||
| 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; | ||
| import org.runimo.runimo.item.domain.EggType; | ||
| import org.runimo.runimo.runimo.exception.RunimoException; | ||
| import org.runimo.runimo.runimo.exception.RunimoHttpResponseCode; | ||
|
|
||
| @Entity | ||
| @Table(name = "runimo") | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @Getter | ||
| public class Runimo extends BaseEntity { | ||
| @Column(name = "name") | ||
| private String name; | ||
|
|
||
| @Column(name = "code", nullable = false) | ||
| private String code; | ||
| @Column(name = "user_id", nullable = false) | ||
| private Long userId; | ||
|
|
||
| @Column(name = "description") | ||
| private String description; | ||
| @Column(name = "runimo_definition_id", nullable = false) | ||
| private Long runimoDefinitionId; | ||
|
|
||
| @Column(name = "img_url") | ||
| private String imgUrl; | ||
| @Column(name = "total_run_count", nullable = false) | ||
| private Long totalRunCount = 0L; | ||
|
|
||
| @Column(name = "total_distance_in_meters", nullable = false) | ||
| private Long totalDistanceInMeters = 0L; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "egg_type", nullable = false) | ||
| private EggType type; | ||
|
|
||
| @Builder | ||
| public Runimo(String name, String code, String description, String imgUrl, EggType type) { | ||
| this.name = name; | ||
| this.code = code; | ||
| this.description = description; | ||
| this.imgUrl = imgUrl; | ||
| this.type = type; | ||
| private Runimo(Long id, Long userId, Long runimoDefinitionId) { | ||
| this.id = id; | ||
| this.userId = userId; | ||
| this.runimoDefinitionId = runimoDefinitionId; | ||
| } | ||
|
|
||
| public void validateOwner(Long userId) { | ||
| if(!this.userId.equals(userId)){ | ||
| throw RunimoException.of(RunimoHttpResponseCode.USER_DO_NOT_OWN_RUNIMO); | ||
| } | ||
|
|
||
| } | ||
| } |
40 changes: 40 additions & 0 deletions
40
src/main/java/org/runimo/runimo/runimo/domain/RunimoDefinition.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,40 @@ | ||
| package org.runimo.runimo.runimo.domain; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import org.runimo.runimo.common.BaseEntity; | ||
| import org.runimo.runimo.item.domain.EggType; | ||
|
|
||
| @Entity | ||
| @Table(name = "runimo_definition") | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @Getter | ||
| public class RunimoDefinition extends BaseEntity { | ||
| @Column(name = "name") | ||
| private String name; | ||
|
|
||
| @Column(name = "code", nullable = false) | ||
| private String code; | ||
|
|
||
| @Column(name = "description") | ||
| private String description; | ||
|
|
||
| @Column(name = "img_url") | ||
| private String imgUrl; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "egg_type", nullable = false) | ||
| private EggType type; | ||
|
|
||
| @Builder | ||
| public RunimoDefinition(String name, String code, String description, String imgUrl, EggType type) { | ||
| this.name = name; | ||
| this.code = code; | ||
| this.description = description; | ||
| this.imgUrl = imgUrl; | ||
| this.type = type; | ||
| } | ||
| } |
30 changes: 0 additions & 30 deletions
30
src/main/java/org/runimo/runimo/runimo/domain/UserRunimo.java
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/main/java/org/runimo/runimo/runimo/repository/RunimoDefinitionRepository.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,10 @@ | ||
| package org.runimo.runimo.runimo.repository; | ||
|
|
||
| import org.runimo.runimo.runimo.domain.RunimoDefinition; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public interface RunimoDefinitionRepository extends JpaRepository<RunimoDefinition, Long> { | ||
| Optional<RunimoDefinition> findByCode(String runimoCode); | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/main/java/org/runimo/runimo/runimo/repository/RunimoRepository.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 |
|---|---|---|
| @@ -1,7 +1,22 @@ | ||
| package org.runimo.runimo.runimo.repository; | ||
|
|
||
| import org.runimo.runimo.runimo.domain.Runimo; | ||
| import org.runimo.runimo.runimo.service.model.RunimoSimpleModel; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface RunimoRepository extends JpaRepository<Runimo, Long> { | ||
|
|
||
| boolean existsByUserIdAndRunimoDefinitionId(Long UserId, Long runimoDefinitionId); | ||
|
|
||
| @Query(""" | ||
| select new org.runimo.runimo.runimo.service.model.RunimoSimpleModel(r.id, r.name, r.imgUrl, r.code, r.type, r.description) | ||
| from Runimo ur | ||
| join RunimoDefinition r on r.id = ur.runimoDefinitionId | ||
| where ur.userId = :userId | ||
| """) | ||
| List<RunimoSimpleModel> findAllByUserId(@Param("userId") Long userId); | ||
| } |
23 changes: 0 additions & 23 deletions
23
src/main/java/org/runimo/runimo/runimo/repository/UserRunimoRepository.java
This file was deleted.
Oops, something went wrong.
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.