diff --git a/src/main/java/org/runimo/runimo/auth/service/SignUpUsecaseImpl.java b/src/main/java/org/runimo/runimo/auth/service/SignUpUsecaseImpl.java index 00b50013..66a98799 100644 --- a/src/main/java/org/runimo/runimo/auth/service/SignUpUsecaseImpl.java +++ b/src/main/java/org/runimo/runimo/auth/service/SignUpUsecaseImpl.java @@ -12,6 +12,7 @@ import org.runimo.runimo.auth.service.dto.UserSignupCommand; import org.runimo.runimo.external.FileStorageService; import org.runimo.runimo.item.domain.Egg; +import org.runimo.runimo.item.domain.EggType; import org.runimo.runimo.rewards.service.eggs.EggGrantService; import org.runimo.runimo.user.domain.AppleUserToken; import org.runimo.runimo.user.domain.SocialProvider; @@ -50,10 +51,11 @@ public SignupUserResponse register(UserSignupCommand command) { createAppleUserToken(savedUser.getId(), signupToken); } Egg grantedEgg = eggGrantService.grantGreetingEggToUser(savedUser); + EggType eggType = grantedEgg.getEggType(); removeSignupToken(payload.token()); return new SignupUserResponse(savedUser, jwtTokenFactory.generateTokenPair(savedUser), - grantedEgg); + grantedEgg, eggType.getCode()); } private void removeSignupToken(String token) { diff --git a/src/main/java/org/runimo/runimo/auth/service/dto/SignupUserResponse.java b/src/main/java/org/runimo/runimo/auth/service/dto/SignupUserResponse.java index 011ade89..c85d4d51 100644 --- a/src/main/java/org/runimo/runimo/auth/service/dto/SignupUserResponse.java +++ b/src/main/java/org/runimo/runimo/auth/service/dto/SignupUserResponse.java @@ -10,17 +10,20 @@ public record SignupUserResponse( TokenPair tokenPair, String greetingEggName, String greetingEggType, - String greetingEggImgUrl + String greetingEggImgUrl, + String eggCode ) { - public SignupUserResponse(final User user, final TokenPair tokenPair, final Egg greetingEgg) { + public SignupUserResponse(final User user, final TokenPair tokenPair, final Egg greetingEgg, + final String eggCode) { this(user.getId(), user.getNickname(), user.getImgUrl(), tokenPair, greetingEgg.getName(), greetingEgg.getEggType().getName(), - greetingEgg.getImgUrl() + greetingEgg.getImgUrl(), + eggCode ); } } diff --git a/src/main/java/org/runimo/runimo/hatch/service/dto/HatchEggResponse.java b/src/main/java/org/runimo/runimo/hatch/service/dto/HatchEggResponse.java index d4924b92..d37dcee1 100644 --- a/src/main/java/org/runimo/runimo/hatch/service/dto/HatchEggResponse.java +++ b/src/main/java/org/runimo/runimo/hatch/service/dto/HatchEggResponse.java @@ -17,7 +17,10 @@ public record HatchEggResponse( String code, @Schema(description = "부화 결과 생성된 러니모를 이미 보유중인지", example = "true") - Boolean isDuplicated + Boolean isDuplicated, + + @Schema(description = "부화 시킨 알의 코드", example = "R-101") + String eggCode ) { } diff --git a/src/main/java/org/runimo/runimo/hatch/service/usecase/HatchUsecaseImpl.java b/src/main/java/org/runimo/runimo/hatch/service/usecase/HatchUsecaseImpl.java index 44d97c79..9b3b887c 100644 --- a/src/main/java/org/runimo/runimo/hatch/service/usecase/HatchUsecaseImpl.java +++ b/src/main/java/org/runimo/runimo/hatch/service/usecase/HatchUsecaseImpl.java @@ -55,7 +55,8 @@ public HatchEggResponse execute(Long userId, Long incubatingEggId) { runimoDefinition.getName(), runimoDefinition.getImgUrl(), runimoDefinition.getCode(), - isDuplicatedRunimo + isDuplicatedRunimo, + egg.getEggType().getCode() ); } diff --git a/src/main/java/org/runimo/runimo/user/repository/IncubatingEggRepository.java b/src/main/java/org/runimo/runimo/user/repository/IncubatingEggRepository.java index 61996a75..4163b588 100644 --- a/src/main/java/org/runimo/runimo/user/repository/IncubatingEggRepository.java +++ b/src/main/java/org/runimo/runimo/user/repository/IncubatingEggRepository.java @@ -26,7 +26,7 @@ public interface IncubatingEggRepository extends JpaRepository findAllByUserId(Long userId); @Query( - "select new org.runimo.runimo.user.service.dto.IncubatingEggView(ie.id, e.name, e.imgUrl, ie.hatchRequireAmount, ie.currentLovePointAmount, ie.status) " + "select new org.runimo.runimo.user.service.dto.IncubatingEggView(ie.id, e.name, e.imgUrl, ie.hatchRequireAmount, ie.currentLovePointAmount, ie.status, e.eggType.code) " + "from IncubatingEgg ie " + "join Egg e on e.id = ie.eggId " + diff --git a/src/main/java/org/runimo/runimo/user/service/dto/IncubatingEggView.java b/src/main/java/org/runimo/runimo/user/service/dto/IncubatingEggView.java index 8bd87a0c..f8ebae3b 100644 --- a/src/main/java/org/runimo/runimo/user/service/dto/IncubatingEggView.java +++ b/src/main/java/org/runimo/runimo/user/service/dto/IncubatingEggView.java @@ -16,15 +16,17 @@ public class IncubatingEggView { private Long hatchRequiredPointAmount; private Long currentLovePointAmount; private Boolean hatchable; + private String eggCode; @Builder public IncubatingEggView(Long id, String name, String imgUrl, Long hatchRequiredPointAmount, - Long currentLovePointAmount, EggStatus hatchable) { + Long currentLovePointAmount, EggStatus hatchable, String eggCode) { this.id = id; this.name = name; this.imgUrl = imgUrl; this.hatchRequiredPointAmount = hatchRequiredPointAmount; this.currentLovePointAmount = currentLovePointAmount; this.hatchable = (hatchable == EggStatus.INCUBATED); + this.eggCode = eggCode; } } diff --git a/src/test/java/org/runimo/runimo/auth/controller/AuthControllerTest.java b/src/test/java/org/runimo/runimo/auth/controller/AuthControllerTest.java index 0784ed2f..18bb3a3d 100644 --- a/src/test/java/org/runimo/runimo/auth/controller/AuthControllerTest.java +++ b/src/test/java/org/runimo/runimo/auth/controller/AuthControllerTest.java @@ -156,7 +156,8 @@ class AuthControllerTest { 1L, "RunimoUser", "profile_url", new TokenPair("access_token", "refresh_token"), "exmaple_egg_name", "example_egg_type", - "example_egg_url" + "example_egg_url", + "ECODE" ) ); @@ -166,7 +167,9 @@ class AuthControllerTest { .param("request", "{\"registerToken\":\"valid-token\", \"nickname\":\"RunimoUser\"}")) .andExpect(status().isCreated()) - .andExpect(jsonPath("$.code").value(UserHttpResponseCode.SIGNUP_SUCCESS.getCode())); + .andExpect(jsonPath("$.payload.egg_code").value("ECODE")) + .andExpect(jsonPath("$.code") + .value(UserHttpResponseCode.SIGNUP_SUCCESS.getCode())); } @Test @@ -192,7 +195,8 @@ class AuthControllerTest { 1L, "RunimoUser", "profile_url", new TokenPair("access_token", "refresh_token"), "exmaple_egg_name", "example_egg_type", - "example_egg_url" + "example_egg_url", + "ECODE" ) ); diff --git a/src/test/java/org/runimo/runimo/hatch/controller/HatchControllerTest.java b/src/test/java/org/runimo/runimo/hatch/controller/HatchControllerTest.java index e4b64a9b..6fa2f0fe 100644 --- a/src/test/java/org/runimo/runimo/hatch/controller/HatchControllerTest.java +++ b/src/test/java/org/runimo/runimo/hatch/controller/HatchControllerTest.java @@ -65,12 +65,13 @@ void tearDown() { .then() .log().all() - .statusCode(HttpStatus.CREATED.value()) + .statusCode(HttpStatus.CREATED.value()) .body("code", equalTo("HSH2011")) .body("payload.name", notNullValue()) .body("payload.img_url", startsWith("http://")) .body("payload.code", startsWith("R-10")) + .body("payload.egg_code", notNullValue()) .body("payload.is_duplicated", anyOf(equalTo(true), equalTo(false))); } } diff --git a/src/test/java/org/runimo/runimo/user/api/UserItemAcceptanceTest.java b/src/test/java/org/runimo/runimo/user/api/UserItemAcceptanceTest.java index d9418f2c..d0567f9c 100644 --- a/src/test/java/org/runimo/runimo/user/api/UserItemAcceptanceTest.java +++ b/src/test/java/org/runimo/runimo/user/api/UserItemAcceptanceTest.java @@ -148,7 +148,8 @@ void tearDown() { new TokenPair(token, "token2"), "마당알", "MADANG", - "test.url" + "test.url", + "ECODE" )); AuthSignupRequest request = new AuthSignupRequest(