Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public record HatchEggResponse(
String code,

@Schema(description = "부화 결과 생성된 러니모를 이미 보유중인지", example = "true")
Boolean isDuplicated
Boolean isDuplicated,

@Schema(description = "부화 시킨 알의 코드", example = "R-101")
String eggCode
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public HatchEggResponse execute(Long userId, Long incubatingEggId) {
runimoDefinition.getName(),
runimoDefinition.getImgUrl(),
runimoDefinition.getCode(),
isDuplicatedRunimo
isDuplicatedRunimo,
egg.getEggType().getCode()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface IncubatingEggRepository extends JpaRepository<IncubatingEgg, In
List<IncubatingEgg> 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 " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
);

Expand All @@ -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
Expand All @@ -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"
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ void tearDown() {
new TokenPair(token, "token2"),
"마당알",
"MADANG",
"test.url"
"test.url",
"ECODE"
));

AuthSignupRequest request = new AuthSignupRequest(
Expand Down