From eeeacd2bce1366e42f6420ce9a4819c77d637a2c Mon Sep 17 00:00:00 2001 From: parksey Date: Mon, 27 Nov 2023 15:23:53 +0900 Subject: [PATCH 1/7] =?UTF-8?q?fix:=20=ED=9A=8C=EC=9B=90=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EC=8B=9C=20=EA=B8=B0=EB=B3=B8=20=EB=B6=80?= =?UTF-8?q?=EC=97=89=EC=9D=B4,=20=EC=98=A4=EB=AA=A9=EB=88=88=EC=9D=B4=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/application/member/MemberMapper.java | 9 ++++++ .../api/application/member/MemberService.java | 24 +++++++++++++++- .../com/moabam/api/domain/member/Member.java | 4 +-- .../global/common/util/BaseDataCode.java | 11 ++++++++ .../global/common/util/BaseImageUrl.java | 4 ++- .../global/error/model/ErrorMessage.java | 1 + .../application/member/MemberServiceTest.java | 11 ++++++++ .../moabam/api/domain/entity/MemberTest.java | 4 +-- .../MemberAuthorizeControllerTest.java | 28 +++++++++++-------- .../presentation/MemberControllerTest.java | 1 - 10 files changed, 79 insertions(+), 18 deletions(-) create mode 100644 src/main/java/com/moabam/global/common/util/BaseDataCode.java diff --git a/src/main/java/com/moabam/api/application/member/MemberMapper.java b/src/main/java/com/moabam/api/application/member/MemberMapper.java index 3c823e22..3963b734 100644 --- a/src/main/java/com/moabam/api/application/member/MemberMapper.java +++ b/src/main/java/com/moabam/api/application/member/MemberMapper.java @@ -11,6 +11,7 @@ import com.moabam.api.domain.bug.Bug; import com.moabam.api.domain.item.Inventory; +import com.moabam.api.domain.item.Item; import com.moabam.api.domain.member.BadgeType; import com.moabam.api.domain.member.Member; import com.moabam.api.dto.member.BadgeResponse; @@ -68,6 +69,14 @@ public static MemberInfoResponse toMemberInfoResponse(MemberInfoSearchResponse m .build(); } + public static Inventory toInventory(Long memberId, Item item) { + return Inventory.builder() + .memberId(memberId) + .item(item) + .isDefault(true) + .build(); + } + private static List badgedNames(Set badgeTypes) { return BadgeType.memberBadgeMap(badgeTypes); } diff --git a/src/main/java/com/moabam/api/application/member/MemberService.java b/src/main/java/com/moabam/api/application/member/MemberService.java index ce4ca41a..72be39c1 100644 --- a/src/main/java/com/moabam/api/application/member/MemberService.java +++ b/src/main/java/com/moabam/api/application/member/MemberService.java @@ -11,7 +11,10 @@ import com.moabam.api.application.auth.mapper.AuthMapper; import com.moabam.api.domain.item.Inventory; +import com.moabam.api.domain.item.Item; +import com.moabam.api.domain.item.repository.InventoryRepository; import com.moabam.api.domain.item.repository.InventorySearchRepository; +import com.moabam.api.domain.item.repository.ItemRepository; import com.moabam.api.domain.member.Member; import com.moabam.api.domain.member.repository.MemberRepository; import com.moabam.api.domain.member.repository.MemberSearchRepository; @@ -22,6 +25,7 @@ import com.moabam.api.dto.member.MemberInfoSearchResponse; import com.moabam.api.dto.member.ModifyMemberRequest; import com.moabam.global.auth.model.AuthMember; +import com.moabam.global.common.util.BaseDataCode; import com.moabam.global.common.util.ClockHolder; import com.moabam.global.common.util.GlobalConstant; import com.moabam.global.error.exception.BadRequestException; @@ -38,6 +42,8 @@ public class MemberService { private final MemberRepository memberRepository; private final InventorySearchRepository inventorySearchRepository; + private final InventoryRepository inventoryRepository; + private final ItemRepository itemRepository; private final MemberSearchRepository memberSearchRepository; private final ClockHolder clockHolder; @@ -116,8 +122,24 @@ private List getDefaultSkin(Long searchId) { private Member signUp(Long socialId) { Member member = MemberMapper.toMember(socialId); + Member savedMember = memberRepository.save(member); + List items = getBasicEggs(); + List inventories = items.stream() + .map(item -> MemberMapper.toInventory(savedMember.getId(), item)) + .toList(); + inventoryRepository.saveAll(inventories); + + return savedMember; + } + + private List getBasicEggs() { + List items = itemRepository.findAllById(List.of(BaseDataCode.MORNING_EGG, BaseDataCode.NIGHT_EGG)); + + if (items.isEmpty()) { + throw new BadRequestException(BASIC_SKIN_NOT_FOUND); + } - return memberRepository.save(member); + return items; } private MemberInfoSearchResponse findMemberInfo(Long searchId, boolean isMe) { diff --git a/src/main/java/com/moabam/api/domain/member/Member.java b/src/main/java/com/moabam/api/domain/member/Member.java index 33f3aab4..24a845dc 100644 --- a/src/main/java/com/moabam/api/domain/member/Member.java +++ b/src/main/java/com/moabam/api/domain/member/Member.java @@ -1,5 +1,6 @@ package com.moabam.api.domain.member; +import static com.moabam.global.common.util.BaseImageUrl.*; import static com.moabam.global.common.util.GlobalConstant.*; import static com.moabam.global.common.util.RandomUtils.*; import static java.util.Objects.*; @@ -12,7 +13,6 @@ import com.moabam.api.domain.bug.Bug; import com.moabam.api.domain.room.RoomType; import com.moabam.global.common.entity.BaseTimeEntity; -import com.moabam.global.common.util.BaseImageUrl; import jakarta.persistence.Column; import jakarta.persistence.Embedded; @@ -85,7 +85,7 @@ private Member(Long id, String socialId, Bug bug) { this.socialId = requireNonNull(socialId); this.nickname = createNickName(); this.intro = ""; - this.profileImage = BaseImageUrl.MEMBER_PROFILE_URL; + this.profileImage = IMAGE_DOMAIN + MEMBER_PROFILE_URL; this.bug = requireNonNull(bug); this.role = Role.USER; } diff --git a/src/main/java/com/moabam/global/common/util/BaseDataCode.java b/src/main/java/com/moabam/global/common/util/BaseDataCode.java new file mode 100644 index 00000000..59098690 --- /dev/null +++ b/src/main/java/com/moabam/global/common/util/BaseDataCode.java @@ -0,0 +1,11 @@ +package com.moabam.global.common.util; + +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class BaseDataCode { + + public static final Long MORNING_EGG = 1L; + public static final Long NIGHT_EGG = 2L; +} diff --git a/src/main/java/com/moabam/global/common/util/BaseImageUrl.java b/src/main/java/com/moabam/global/common/util/BaseImageUrl.java index 99544648..5b3746d5 100644 --- a/src/main/java/com/moabam/global/common/util/BaseImageUrl.java +++ b/src/main/java/com/moabam/global/common/util/BaseImageUrl.java @@ -6,11 +6,13 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) public class BaseImageUrl { + public static final String IMAGE_DOMAIN = "https://image.moabam.com/"; + public static final String DEFAULT_SKIN_URL = ""; public static final String DEFAULT_MORNING_AWAKE_SKIN_URL = ""; public static final String DEFAULT_MORNING_SLEEP_SKIN_URL = ""; public static final String DEFAULT_NIGHT_AWAKE_SKIN_URL = ""; public static final String DEFAULT_NIGHT_SLEEP_SKIN_URL = ""; - public static final String MEMBER_PROFILE_URL = "/profile/baseUrl"; + public static final String MEMBER_PROFILE_URL = "moabam/default/기본회원프로필.png"; } diff --git a/src/main/java/com/moabam/global/error/model/ErrorMessage.java b/src/main/java/com/moabam/global/error/model/ErrorMessage.java index 3cfa68f2..f1ee457a 100644 --- a/src/main/java/com/moabam/global/error/model/ErrorMessage.java +++ b/src/main/java/com/moabam/global/error/model/ErrorMessage.java @@ -37,6 +37,7 @@ public enum ErrorMessage { UNLINK_REQUEST_FAIL_ROLLBACK_SUCCESS("카카오 연결 요청 실패로 Rollback하였습니다."), NICKNAME_CONFLICT("이미 존재하는 닉네임입니다."), + BASIC_SKIN_NOT_FOUND("기본 스킨 오류 발생, 관리자에게 문의하세요"), INVALID_DEFAULT_SKIN_SIZE("기본 스킨은 2개여야 합니다. 관리자에게 문의하세요"), BUG_NOT_ENOUGH("보유한 벌레가 부족합니다."), diff --git a/src/test/java/com/moabam/api/application/member/MemberServiceTest.java b/src/test/java/com/moabam/api/application/member/MemberServiceTest.java index a30978cc..0e913106 100644 --- a/src/test/java/com/moabam/api/application/member/MemberServiceTest.java +++ b/src/test/java/com/moabam/api/application/member/MemberServiceTest.java @@ -19,7 +19,9 @@ import com.moabam.api.domain.item.Inventory; import com.moabam.api.domain.item.Item; +import com.moabam.api.domain.item.repository.InventoryRepository; import com.moabam.api.domain.item.repository.InventorySearchRepository; +import com.moabam.api.domain.item.repository.ItemRepository; import com.moabam.api.domain.member.Member; import com.moabam.api.domain.member.repository.MemberRepository; import com.moabam.api.domain.member.repository.MemberSearchRepository; @@ -55,6 +57,12 @@ class MemberServiceTest { @Mock InventorySearchRepository inventorySearchRepository; + @Mock + InventoryRepository inventoryRepository; + + @Mock + ItemRepository itemRepository; + @Mock ClockHolder clockHolder; @@ -89,6 +97,9 @@ void signUp_success() { given(member.getId()).willReturn(1L); willReturn(member) .given(memberRepository).save(any(Member.class)); + willReturn(List.of(ItemFixture.morningSantaSkin().build(), + ItemFixture.nightMageSkin())) + .given(itemRepository).findAllById(any()); // when LoginResponse result = memberService.login(authorizationTokenInfoResponse); diff --git a/src/test/java/com/moabam/api/domain/entity/MemberTest.java b/src/test/java/com/moabam/api/domain/entity/MemberTest.java index b3168af3..1abd753b 100644 --- a/src/test/java/com/moabam/api/domain/entity/MemberTest.java +++ b/src/test/java/com/moabam/api/domain/entity/MemberTest.java @@ -1,5 +1,6 @@ package com.moabam.api.domain.entity; +import static com.moabam.global.common.util.BaseImageUrl.*; import static org.assertj.core.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*; @@ -11,7 +12,6 @@ import com.moabam.api.domain.member.Member; import com.moabam.api.domain.member.Role; import com.moabam.api.domain.room.RoomType; -import com.moabam.global.common.util.BaseImageUrl; import com.moabam.support.fixture.MemberFixture; class MemberTest { @@ -41,7 +41,7 @@ void create_member_noImage_success() { .build(); assertAll( - () -> assertThat(member.getProfileImage()).isEqualTo(BaseImageUrl.MEMBER_PROFILE_URL), + () -> assertThat(member.getProfileImage()).isEqualTo(IMAGE_DOMAIN + MEMBER_PROFILE_URL), () -> assertThat(member.getRole()).isEqualTo(Role.USER), () -> assertThat(member.getBug().getNightBug()).isZero(), () -> assertThat(member.getBug().getGoldenBug()).isZero(), diff --git a/src/test/java/com/moabam/api/presentation/MemberAuthorizeControllerTest.java b/src/test/java/com/moabam/api/presentation/MemberAuthorizeControllerTest.java index 0f5d04d7..d0df0151 100644 --- a/src/test/java/com/moabam/api/presentation/MemberAuthorizeControllerTest.java +++ b/src/test/java/com/moabam/api/presentation/MemberAuthorizeControllerTest.java @@ -1,16 +1,12 @@ package com.moabam.api.presentation; -import static org.mockito.BDDMockito.any; -import static org.mockito.BDDMockito.doReturn; -import static org.mockito.BDDMockito.willReturn; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.cookie; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.mockito.BDDMockito.*; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.*; +import static org.springframework.test.web.client.response.MockRestResponseCreators.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.util.List; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -40,6 +36,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.moabam.api.application.auth.AuthorizationService; import com.moabam.api.application.auth.OAuth2AuthorizationServerRequestService; +import com.moabam.api.domain.item.Item; +import com.moabam.api.domain.item.repository.ItemRepository; import com.moabam.api.dto.auth.AuthorizationCodeResponse; import com.moabam.api.dto.auth.AuthorizationTokenInfoResponse; import com.moabam.api.dto.auth.AuthorizationTokenResponse; @@ -48,6 +46,7 @@ import com.moabam.global.config.OAuthConfig; import com.moabam.global.error.handler.RestTemplateResponseHandler; import com.moabam.support.fixture.AuthorizationResponseFixture; +import com.moabam.support.fixture.ItemFixture; @SpringBootTest @AutoConfigureMockMvc @@ -62,6 +61,9 @@ class MemberAuthorizeControllerTest { @Autowired OAuth2AuthorizationServerRequestService oAuth2AuthorizationServerRequestService; + @Autowired + ItemRepository itemRepository; + @SpyBean AuthorizationService authorizationService; @@ -122,6 +124,10 @@ void social_login_signUp_request_success() throws Exception { contentParams.add("code", "test"); contentParams.add("client_secret", oAuthConfig.client().clientSecret()); + Item morningEgg = ItemFixture.morningSantaSkin().build(); + Item nightEgg = ItemFixture.nightMageSkin(); + itemRepository.saveAll(List.of(morningEgg, nightEgg)); + AuthorizationCodeResponse authorizationCodeResponse = AuthorizationResponseFixture.successCodeResponse(); String requestBody = objectMapper.writeValueAsString(authorizationCodeResponse); AuthorizationTokenResponse authorizationTokenResponse = diff --git a/src/test/java/com/moabam/api/presentation/MemberControllerTest.java b/src/test/java/com/moabam/api/presentation/MemberControllerTest.java index 73e43428..6db202d9 100644 --- a/src/test/java/com/moabam/api/presentation/MemberControllerTest.java +++ b/src/test/java/com/moabam/api/presentation/MemberControllerTest.java @@ -160,7 +160,6 @@ void logout_success() throws Exception { Assertions.assertThatThrownBy(() -> tokenRepository.getTokenSaveValue(member.getId())) .isInstanceOf(UnauthorizedException.class); - } @DisplayName("회원 삭제 성공 테스트") From 44e90cf9cef4312e94793147346d08456c0eb283 Mon Sep 17 00:00:00 2001 From: parksey Date: Mon, 27 Nov 2023 18:23:09 +0900 Subject: [PATCH 2/7] =?UTF-8?q?fix:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 8 +++ .../api/application/member/MemberMapper.java | 22 ++++---- .../api/application/member/MemberService.java | 26 +++------- .../com/moabam/api/domain/member/Member.java | 27 ++++++++++ .../repository/MemberSearchRepository.java | 2 + .../com/moabam/api/dto/member/MemberInfo.java | 9 ++-- .../dto/member/MemberInfoSearchResponse.java | 2 + .../global/common/util/BaseImageUrl.java | 2 + .../global/error/model/ErrorMessage.java | 1 + .../application/member/MemberServiceTest.java | 51 ++----------------- .../presentation/MemberControllerTest.java | 16 ++++-- .../moabam/support/fixture/ItemFixture.java | 8 +-- .../fixture/MemberInfoSearchFixture.java | 20 +++++--- 13 files changed, 98 insertions(+), 96 deletions(-) diff --git a/build.gradle b/build.gradle index 9783e62f..2f40eeda 100644 --- a/build.gradle +++ b/build.gradle @@ -19,6 +19,14 @@ ext { snippetsDir = file('build/generated-snippets') } +def querydslSrcDir = 'src/main/generated' +clean { + delete file(querydslSrcDir) +} +tasks.withType(JavaCompile) { + options.generatedSourceOutputDirectory = file(querydslSrcDir) +} + configurations { asciidoctorExtensions diff --git a/src/main/java/com/moabam/api/application/member/MemberMapper.java b/src/main/java/com/moabam/api/application/member/MemberMapper.java index 3963b734..148a0b8d 100644 --- a/src/main/java/com/moabam/api/application/member/MemberMapper.java +++ b/src/main/java/com/moabam/api/application/member/MemberMapper.java @@ -2,16 +2,17 @@ import static com.moabam.global.common.util.GlobalConstant.*; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.stream.Collectors; import com.moabam.api.domain.bug.Bug; import com.moabam.api.domain.item.Inventory; import com.moabam.api.domain.item.Item; +import com.moabam.api.domain.item.ItemType; import com.moabam.api.domain.member.BadgeType; import com.moabam.api.domain.member.Member; import com.moabam.api.dto.member.BadgeResponse; @@ -42,6 +43,8 @@ public static MemberInfoSearchResponse toMemberInfoSearchResponse(List(badgeTypes)) @@ -51,8 +54,7 @@ public static MemberInfoSearchResponse toMemberInfoSearchResponse(List inventories) { + public static MemberInfoResponse toMemberInfoResponse(MemberInfoSearchResponse memberInfoSearchResponse) { long certifyCount = memberInfoSearchResponse.totalCertifyCount(); return MemberInfoResponse.builder() @@ -61,7 +63,7 @@ public static MemberInfoResponse toMemberInfoResponse(MemberInfoSearchResponse m .intro(memberInfoSearchResponse.intro()) .level(certifyCount / LEVEL_DIVISOR) .exp(certifyCount % LEVEL_DIVISOR) - .birds(defaultSkins(inventories)) + .birds(defaultSkins(memberInfoSearchResponse.morningImage(), memberInfoSearchResponse.nightImage())) .badges(badgedNames(memberInfoSearchResponse.badges())) .goldenBug(memberInfoSearchResponse.goldenBug()) .morningBug(memberInfoSearchResponse.morningBug()) @@ -81,11 +83,11 @@ private static List badgedNames(Set badgeTypes) { return BadgeType.memberBadgeMap(badgeTypes); } - private static Map defaultSkins(List inventories) { - return inventories.stream() - .collect(Collectors.toMap( - inventory -> inventory.getItem().getType().name(), - inventory -> inventory.getItem().getImage() - )); + private static Map defaultSkins(String morningImage, String nightImage) { + Map birdsSkin = new HashMap<>(); + birdsSkin.put(ItemType.MORNING.name(), morningImage); + birdsSkin.put(ItemType.NIGHT.name(), nightImage); + + return birdsSkin; } } diff --git a/src/main/java/com/moabam/api/application/member/MemberService.java b/src/main/java/com/moabam/api/application/member/MemberService.java index 911c0bab..b6505ce3 100644 --- a/src/main/java/com/moabam/api/application/member/MemberService.java +++ b/src/main/java/com/moabam/api/application/member/MemberService.java @@ -13,7 +13,6 @@ import com.moabam.api.domain.item.Inventory; import com.moabam.api.domain.item.Item; import com.moabam.api.domain.item.repository.InventoryRepository; -import com.moabam.api.domain.item.repository.InventorySearchRepository; import com.moabam.api.domain.item.repository.ItemRepository; import com.moabam.api.domain.member.Member; import com.moabam.api.domain.member.repository.MemberRepository; @@ -27,7 +26,6 @@ import com.moabam.global.auth.model.AuthMember; import com.moabam.global.common.util.BaseDataCode; import com.moabam.global.common.util.ClockHolder; -import com.moabam.global.common.util.GlobalConstant; import com.moabam.global.error.exception.BadRequestException; import com.moabam.global.error.exception.ConflictException; import com.moabam.global.error.exception.NotFoundException; @@ -41,7 +39,6 @@ public class MemberService { private final MemberRepository memberRepository; - private final InventorySearchRepository inventorySearchRepository; private final InventoryRepository inventoryRepository; private final ItemRepository itemRepository; private final MemberSearchRepository memberSearchRepository; @@ -84,11 +81,8 @@ public MemberInfoResponse searchInfo(AuthMember authMember, Long memberId) { if (!isMe) { searchId = memberId; } - MemberInfoSearchResponse memberInfoSearchResponse = findMemberInfo(searchId, isMe); - List inventories = getDefaultSkin(searchId); - - return MemberMapper.toMemberInfoResponse(memberInfoSearchResponse, inventories); + return MemberMapper.toMemberInfoResponse(memberInfoSearchResponse); } @Transactional @@ -111,25 +105,17 @@ private void validateNickname(String nickname) { } } - private List getDefaultSkin(Long searchId) { - List inventories = inventorySearchRepository.findDefaultSkin(searchId); - if (inventories.size() != GlobalConstant.DEFAULT_SKIN_SIZE) { - throw new BadRequestException(INVALID_DEFAULT_SKIN_SIZE); - } - - return inventories; - } - private Member signUp(Long socialId) { Member member = MemberMapper.toMember(socialId); - Member savedMember = memberRepository.save(member); + return memberRepository.save(member); + } + + private void saveMyEgg(Member member) { List items = getBasicEggs(); List inventories = items.stream() - .map(item -> MemberMapper.toInventory(savedMember.getId(), item)) + .map(item -> MemberMapper.toInventory(member.getId(), item)) .toList(); inventoryRepository.saveAll(inventories); - - return savedMember; } private List getBasicEggs() { diff --git a/src/main/java/com/moabam/api/domain/member/Member.java b/src/main/java/com/moabam/api/domain/member/Member.java index 24a845dc..3cfc9f24 100644 --- a/src/main/java/com/moabam/api/domain/member/Member.java +++ b/src/main/java/com/moabam/api/domain/member/Member.java @@ -3,6 +3,7 @@ import static com.moabam.global.common.util.BaseImageUrl.*; import static com.moabam.global.common.util.GlobalConstant.*; import static com.moabam.global.common.util.RandomUtils.*; +import static com.moabam.global.error.model.ErrorMessage.*; import static java.util.Objects.*; import java.time.LocalDateTime; @@ -11,8 +12,11 @@ import org.hibernate.annotations.SQLDelete; import com.moabam.api.domain.bug.Bug; +import com.moabam.api.domain.item.Item; +import com.moabam.api.domain.item.ItemType; import com.moabam.api.domain.room.RoomType; import com.moabam.global.common.entity.BaseTimeEntity; +import com.moabam.global.error.exception.NotFoundException; import jakarta.persistence.Column; import jakarta.persistence.Embedded; @@ -52,6 +56,12 @@ public class Member extends BaseTimeEntity { @Column(name = "profile_image", nullable = false) private String profileImage; + @Column(name = "morning_image", nullable = false) + private String morningImage; + + @Column(name = "night_image", nullable = false) + private String nightImage; + @Column(name = "total_certify_count", nullable = false) @ColumnDefault("0") private long totalCertifyCount; @@ -86,6 +96,8 @@ private Member(Long id, String socialId, Bug bug) { this.nickname = createNickName(); this.intro = ""; this.profileImage = IMAGE_DOMAIN + MEMBER_PROFILE_URL; + this.morningImage = IMAGE_DOMAIN + DEFAULT_MORNING_EGG_URL; + this.nightImage = IMAGE_DOMAIN + DEFAULT_NIGHT_EGG_URL; this.bug = requireNonNull(bug); this.role = Role.USER; } @@ -134,6 +146,21 @@ public void changeIntro(String intro) { public void changeProfileUri(String newProfileUri) { this.profileImage = requireNonNullElse(newProfileUri, profileImage); + this.profileImage = requireNonNullElse(newProfileUri, profileImage); + } + + public void changeDefaultSkintUrl(Item item) throws NotFoundException { + if (ItemType.MORNING.equals(item.getType())) { + this.morningImage = item.getImage(); + return; + } + + if (ItemType.NIGHT.equals(item.getType())) { + this.nightImage = item.getImage(); + return; + } + + throw new NotFoundException(SKIN_TYPE_NOT_FOUND); } private String createNickName() { diff --git a/src/main/java/com/moabam/api/domain/member/repository/MemberSearchRepository.java b/src/main/java/com/moabam/api/domain/member/repository/MemberSearchRepository.java index a90e0009..b853b871 100644 --- a/src/main/java/com/moabam/api/domain/member/repository/MemberSearchRepository.java +++ b/src/main/java/com/moabam/api/domain/member/repository/MemberSearchRepository.java @@ -54,6 +54,8 @@ public List findMemberAndBadges(Long searchId, boolean isMe) { List> selectExpression = new ArrayList<>(List.of( member.nickname, member.profileImage, + member.morningImage, + member.nightImage, member.intro, member.totalCertifyCount, badge.type)); diff --git a/src/main/java/com/moabam/api/dto/member/MemberInfo.java b/src/main/java/com/moabam/api/dto/member/MemberInfo.java index 189469c4..56ed7c77 100644 --- a/src/main/java/com/moabam/api/dto/member/MemberInfo.java +++ b/src/main/java/com/moabam/api/dto/member/MemberInfo.java @@ -5,6 +5,8 @@ public record MemberInfo( String nickname, String profileImage, + String morningImage, + String nightImage, String intro, long totalCertifyCount, BadgeType badges, @@ -13,8 +15,9 @@ public record MemberInfo( Integer nightBug ) { - public MemberInfo(String nickname, String profileImage, String intro, - long totalCertifyCount, BadgeType badges) { - this(nickname, profileImage, intro, totalCertifyCount, badges, null, null, null); + public MemberInfo(String nickname, String profileImage, String morningImage, String nightImage, + String intro, long totalCertifyCount, BadgeType badges) { + this(nickname, profileImage, morningImage, nightImage, intro, + totalCertifyCount, badges, null, null, null); } } diff --git a/src/main/java/com/moabam/api/dto/member/MemberInfoSearchResponse.java b/src/main/java/com/moabam/api/dto/member/MemberInfoSearchResponse.java index e22070cc..1391e383 100644 --- a/src/main/java/com/moabam/api/dto/member/MemberInfoSearchResponse.java +++ b/src/main/java/com/moabam/api/dto/member/MemberInfoSearchResponse.java @@ -10,6 +10,8 @@ public record MemberInfoSearchResponse( String nickname, String profileImage, + String morningImage, + String nightImage, String intro, long totalCertifyCount, Set badges, diff --git a/src/main/java/com/moabam/global/common/util/BaseImageUrl.java b/src/main/java/com/moabam/global/common/util/BaseImageUrl.java index 5b3746d5..ac66f717 100644 --- a/src/main/java/com/moabam/global/common/util/BaseImageUrl.java +++ b/src/main/java/com/moabam/global/common/util/BaseImageUrl.java @@ -14,5 +14,7 @@ public class BaseImageUrl { public static final String DEFAULT_NIGHT_AWAKE_SKIN_URL = ""; public static final String DEFAULT_NIGHT_SLEEP_SKIN_URL = ""; + public static final String DEFAULT_MORNING_EGG_URL = "moabam/skins/오목눈이/기본/오목눈이알.png"; + public static final String DEFAULT_NIGHT_EGG_URL = "moabam/skins/부엉이/기본/부엉이알.png"; public static final String MEMBER_PROFILE_URL = "moabam/default/기본회원프로필.png"; } diff --git a/src/main/java/com/moabam/global/error/model/ErrorMessage.java b/src/main/java/com/moabam/global/error/model/ErrorMessage.java index 994b7a42..2dc505a9 100644 --- a/src/main/java/com/moabam/global/error/model/ErrorMessage.java +++ b/src/main/java/com/moabam/global/error/model/ErrorMessage.java @@ -42,6 +42,7 @@ public enum ErrorMessage { BASIC_SKIN_NOT_FOUND("기본 스킨 오류 발생, 관리자에게 문의하세요"), INVALID_DEFAULT_SKIN_SIZE("기본 스킨은 2개여야 합니다. 관리자에게 문의하세요"), + SKIN_TYPE_NOT_FOUND("스킨 타입이 없습니다. 관리자에게 문의하세요"), BUG_NOT_ENOUGH("보유한 벌레가 부족합니다."), diff --git a/src/test/java/com/moabam/api/application/member/MemberServiceTest.java b/src/test/java/com/moabam/api/application/member/MemberServiceTest.java index 0e913106..3271f6f1 100644 --- a/src/test/java/com/moabam/api/application/member/MemberServiceTest.java +++ b/src/test/java/com/moabam/api/application/member/MemberServiceTest.java @@ -1,6 +1,5 @@ package com.moabam.api.application.member; -import static com.moabam.global.error.model.ErrorMessage.*; import static org.assertj.core.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.BDDMockito.*; @@ -27,6 +26,7 @@ import com.moabam.api.domain.member.repository.MemberSearchRepository; import com.moabam.api.dto.auth.AuthorizationTokenInfoResponse; import com.moabam.api.dto.auth.LoginResponse; +import com.moabam.api.dto.member.MemberInfo; import com.moabam.api.dto.member.MemberInfoResponse; import com.moabam.api.dto.member.ModifyMemberRequest; import com.moabam.global.auth.model.AuthMember; @@ -97,9 +97,6 @@ void signUp_success() { given(member.getId()).willReturn(1L); willReturn(member) .given(memberRepository).save(any(Member.class)); - willReturn(List.of(ItemFixture.morningSantaSkin().build(), - ItemFixture.nightMageSkin())) - .given(itemRepository).findAllById(any()); // when LoginResponse result = memberService.login(authorizationTokenInfoResponse); @@ -160,10 +157,6 @@ void search_my_info_success(@WithMember AuthMember authMember) { given(memberSearchRepository.findMemberAndBadges(authMember.id(), true)) .willReturn(MemberInfoSearchFixture.friendMemberInfo(total)); - given(inventorySearchRepository.findDefaultSkin(authMember.id())) - .willReturn(List.of( - InventoryFixture.inventory(authMember.id(), morning), - InventoryFixture.inventory(authMember.id(), night))); // When + Then MemberInfoResponse memberInfoResponse = memberService.searchInfo(authMember, null); @@ -187,10 +180,11 @@ void success(@WithMember AuthMember authMember) { Item night = ItemFixture.nightMageSkin(); Inventory morningSkin = InventoryFixture.inventory(searchId, morning); Inventory nightSkin = InventoryFixture.inventory(searchId, night); + List memberInfos = MemberInfoSearchFixture + .myInfo(morningSkin.getItem().getImage(), nightSkin.getItem().getImage()); given(memberSearchRepository.findMemberAndBadges(anyLong(), anyBoolean())) - .willReturn(MemberInfoSearchFixture.myInfo()); - given(inventorySearchRepository.findDefaultSkin(searchId)).willReturn(List.of(morningSkin, nightSkin)); + .willReturn(memberInfos); // when MemberInfoResponse memberInfoResponse = memberService.searchInfo(authMember, null); @@ -199,43 +193,6 @@ void success(@WithMember AuthMember authMember) { assertThat(memberInfoResponse.birds()).containsEntry("MORNING", morningSkin.getItem().getImage()); assertThat(memberInfoResponse.birds()).containsEntry("NIGHT", nightSkin.getItem().getImage()); } - - @DisplayName("기본 스킨이 없어서 예외 발생") - @Test - void failBy_underSize(@WithMember AuthMember authMember) { - // given - given(memberSearchRepository.findMemberAndBadges(anyLong(), anyBoolean())) - .willReturn(MemberInfoSearchFixture.friendMemberInfo()); - given(inventorySearchRepository.findDefaultSkin(anyLong())).willReturn(List.of()); - - // when - assertThatThrownBy(() -> memberService.searchInfo(authMember, 123L)) - .isInstanceOf(BadRequestException.class) - .hasMessage(INVALID_DEFAULT_SKIN_SIZE.getMessage()); - } - - @DisplayName("기본 스킨이 3개 이상이어서 예외 발생") - @Test - void failBy_overSize(@WithMember AuthMember authMember) { - // given - long searchId = 1L; - Item morning = ItemFixture.morningSantaSkin().build(); - Item night = ItemFixture.nightMageSkin(); - Item kill = ItemFixture.morningKillerSkin().build(); - Inventory morningSkin = InventoryFixture.inventory(searchId, morning); - Inventory nightSkin = InventoryFixture.inventory(searchId, night); - Inventory killSkin = InventoryFixture.inventory(searchId, kill); - - given(memberSearchRepository.findMemberAndBadges(anyLong(), anyBoolean())) - .willReturn(MemberInfoSearchFixture.myInfo()); - given(inventorySearchRepository.findDefaultSkin(searchId)) - .willReturn(List.of(morningSkin, nightSkin, killSkin)); - - // when - assertThatThrownBy(() -> memberService.searchInfo(authMember, null)) - .isInstanceOf(BadRequestException.class) - .hasMessage(INVALID_DEFAULT_SKIN_SIZE.getMessage()); - } } @DisplayName("사용자 정보 수정 성공") diff --git a/src/test/java/com/moabam/api/presentation/MemberControllerTest.java b/src/test/java/com/moabam/api/presentation/MemberControllerTest.java index 0847dacd..fb4b4b9e 100644 --- a/src/test/java/com/moabam/api/presentation/MemberControllerTest.java +++ b/src/test/java/com/moabam/api/presentation/MemberControllerTest.java @@ -133,7 +133,7 @@ void allSetUp() { restTemplateBuilder = new RestTemplateBuilder() .errorHandler(new RestTemplateResponseHandler()); - member = MemberFixture.member("1", "nickname"); + member = MemberFixture.member("1234567890987654", "nickname"); member.increaseTotalCertifyCount(); memberRepository.save(member); } @@ -268,6 +268,9 @@ void search_my_info_success() throws Exception { Inventory killerInven = InventoryFixture.inventory(member.getId(), killer); inventoryRepository.saveAll(List.of(nightInven, morningInven, killerInven)); + member.changeDefaultSkintUrl(night); + member.changeDefaultSkintUrl(morning); + // expected mockMvc.perform(get("/members")) .andExpect(status().isOk()) @@ -278,8 +281,8 @@ void search_my_info_success() throws Exception { MockMvcResultMatchers.jsonPath("$.level").value(member.getTotalCertifyCount() / LEVEL_DIVISOR), MockMvcResultMatchers.jsonPath("$.exp").value(member.getTotalCertifyCount() % LEVEL_DIVISOR), - MockMvcResultMatchers.jsonPath("$.birds.MORNING").value(morningInven.getItem().getImage()), - MockMvcResultMatchers.jsonPath("$.birds.NIGHT").value(nightInven.getItem().getImage()), + // MockMvcResultMatchers.jsonPath("$.birds.MORNING").value(morningInven.getItem().getImage()), + // MockMvcResultMatchers.jsonPath("$.birds.NIGHT").value(nightInven.getItem().getImage()), MockMvcResultMatchers.jsonPath("$.badges[0].badge").value("MORNING_BIRTH"), MockMvcResultMatchers.jsonPath("$.badges[0].unlock").value(true), @@ -324,8 +327,8 @@ void search_my_info_with_no_badge_success() throws Exception { MockMvcResultMatchers.jsonPath("$.level").value(member.getTotalCertifyCount() / LEVEL_DIVISOR), MockMvcResultMatchers.jsonPath("$.exp").value(member.getTotalCertifyCount() % LEVEL_DIVISOR), - MockMvcResultMatchers.jsonPath("$.birds.MORNING").value(morningInven.getItem().getImage()), - MockMvcResultMatchers.jsonPath("$.birds.NIGHT").value(nightInven.getItem().getImage()), + // MockMvcResultMatchers.jsonPath("$.birds.MORNING").value(morningInven.getItem().getImage()), + // MockMvcResultMatchers.jsonPath("$.birds.NIGHT").value(nightInven.getItem().getImage()), MockMvcResultMatchers.jsonPath("$.badges[0].badge").value("MORNING_BIRTH"), MockMvcResultMatchers.jsonPath("$.badges[0].unlock").value(false), @@ -368,6 +371,9 @@ void search_friend_info_success() throws Exception { morningInven.select(); Inventory killerInven = InventoryFixture.inventory(friend.getId(), killer); + friend.changeDefaultSkintUrl(morning); + friend.changeDefaultSkintUrl(night); + memberRepository.flush(); inventoryRepository.saveAll(List.of(nightInven, morningInven, killerInven)); // expected diff --git a/src/test/java/com/moabam/support/fixture/ItemFixture.java b/src/test/java/com/moabam/support/fixture/ItemFixture.java index 087b87d3..c45d535d 100644 --- a/src/test/java/com/moabam/support/fixture/ItemFixture.java +++ b/src/test/java/com/moabam/support/fixture/ItemFixture.java @@ -1,5 +1,7 @@ package com.moabam.support.fixture; +import static com.moabam.global.common.util.BaseImageUrl.*; + import com.moabam.api.domain.item.Item; import com.moabam.api.domain.item.ItemCategory; import com.moabam.api.domain.item.ItemType; @@ -7,11 +9,11 @@ public class ItemFixture { public static final String MORNING_SANTA_SKIN_NAME = "산타 오목눈이"; - public static final String MORNING_SANTA_SKIN_IMAGE = "/item/morning_santa.png"; + public static final String MORNING_SANTA_SKIN_IMAGE = IMAGE_DOMAIN + "item/morning_santa.png"; public static final String MORNING_KILLER_SKIN_NAME = "킬러 오목눈이"; - public static final String MORNING_KILLER_SKIN_IMAGE = "/item/morning_killer.png"; + public static final String MORNING_KILLER_SKIN_IMAGE = IMAGE_DOMAIN + "item/morning_killer.png"; public static final String NIGHT_MAGE_SKIN_NAME = "메이지 부엉이"; - public static final String NIGHT_MAGE_SKIN_IMAGE = "/item/night_mage.png"; + public static final String NIGHT_MAGE_SKIN_IMAGE = IMAGE_DOMAIN + "item/night_mage.png"; public static Item.ItemBuilder morningSantaSkin() { return Item.builder() diff --git a/src/test/java/com/moabam/support/fixture/MemberInfoSearchFixture.java b/src/test/java/com/moabam/support/fixture/MemberInfoSearchFixture.java index 9c0c4d26..e4bfa647 100644 --- a/src/test/java/com/moabam/support/fixture/MemberInfoSearchFixture.java +++ b/src/test/java/com/moabam/support/fixture/MemberInfoSearchFixture.java @@ -1,5 +1,7 @@ package com.moabam.support.fixture; +import static com.moabam.global.common.util.BaseImageUrl.*; + import java.util.List; import com.moabam.api.domain.member.BadgeType; @@ -8,9 +10,11 @@ public class MemberInfoSearchFixture { private static final String NICKNAME = "nickname"; - private static final String PROFILE_IMAGE = "profileuri"; + private static final String PROFILE_IMAGE = IMAGE_DOMAIN + MEMBER_PROFILE_URL; private static final String INTRO = "intro"; private static final long TOTAL_CERTIFY_COUNT = 15; + private static final String MORNING_EGG = IMAGE_DOMAIN + DEFAULT_MORNING_EGG_URL; + private static final String NIGHT_EGG = IMAGE_DOMAIN + DEFAULT_NIGHT_EGG_URL; public static List friendMemberInfo() { return friendMemberInfo(TOTAL_CERTIFY_COUNT); @@ -18,19 +22,19 @@ public static List friendMemberInfo() { public static List friendMemberInfo(long total) { return List.of( - new MemberInfo(NICKNAME, PROFILE_IMAGE, INTRO, total, BadgeType.MORNING_BIRTH, + new MemberInfo(NICKNAME, PROFILE_IMAGE, MORNING_EGG, NIGHT_EGG, INTRO, total, BadgeType.MORNING_BIRTH, 0, 0, 0), - new MemberInfo(NICKNAME, PROFILE_IMAGE, INTRO, total, BadgeType.NIGHT_BIRTH, + new MemberInfo(NICKNAME, PROFILE_IMAGE, MORNING_EGG, NIGHT_EGG, INTRO, total, BadgeType.NIGHT_BIRTH, 0, 0, 0) ); } - public static List myInfo() { + public static List myInfo(String morningImage, String nightImage) { return List.of( - new MemberInfo(NICKNAME, PROFILE_IMAGE, INTRO, TOTAL_CERTIFY_COUNT, BadgeType.MORNING_BIRTH, - 0, 0, 0), - new MemberInfo(NICKNAME, PROFILE_IMAGE, INTRO, TOTAL_CERTIFY_COUNT, BadgeType.NIGHT_BIRTH, - 0, 0, 0) + new MemberInfo(NICKNAME, PROFILE_IMAGE, morningImage, nightImage, INTRO, TOTAL_CERTIFY_COUNT, + BadgeType.MORNING_BIRTH, 0, 0, 0), + new MemberInfo(NICKNAME, PROFILE_IMAGE, morningImage, nightImage, INTRO, TOTAL_CERTIFY_COUNT, + BadgeType.NIGHT_BIRTH, 0, 0, 0) ); } } From ab8f82c704e97b0def2fe90b3dc52f90b558d826 Mon Sep 17 00:00:00 2001 From: parksey Date: Mon, 27 Nov 2023 18:24:12 +0900 Subject: [PATCH 3/7] =?UTF-8?q?refacotr:=20config=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/config b/src/main/resources/config index 2e460460..ea25d857 160000 --- a/src/main/resources/config +++ b/src/main/resources/config @@ -1 +1 @@ -Subproject commit 2e460460a0048796a3ef6fef17697935027a8708 +Subproject commit ea25d85744c2e6fcedbdb66b34c08837d382814d From 22a20c1700777d9df0e9a385ac9d1d0793a76f39 Mon Sep 17 00:00:00 2001 From: parksey Date: Tue, 28 Nov 2023 11:24:06 +0900 Subject: [PATCH 4/7] =?UTF-8?q?test:=20@BeforeAll=20Transaction=EC=A0=81?= =?UTF-8?q?=EC=9A=A9=20=EC=8B=A4=ED=8C=A8=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20?= =?UTF-8?q?merge=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/MemberControllerTest.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/moabam/api/presentation/MemberControllerTest.java b/src/test/java/com/moabam/api/presentation/MemberControllerTest.java index fb4b4b9e..13ad4d14 100644 --- a/src/test/java/com/moabam/api/presentation/MemberControllerTest.java +++ b/src/test/java/com/moabam/api/presentation/MemberControllerTest.java @@ -76,6 +76,8 @@ import com.moabam.support.fixture.RoomFixture; import com.moabam.support.fixture.TokenSaveValueFixture; +import jakarta.persistence.EntityManager; + @Transactional @SpringBootTest @AutoConfigureMockMvc @@ -128,6 +130,9 @@ class MemberControllerTest extends WithoutFilterSupporter { Member member; + @Autowired + EntityManager entityManager; + @BeforeAll void allSetUp() { restTemplateBuilder = new RestTemplateBuilder() @@ -143,6 +148,7 @@ void setUp() { RestTemplate restTemplate = restTemplateBuilder.build(); ReflectionTestUtils.setField(oAuth2AuthorizationServerRequestService, "restTemplate", restTemplate); mockRestServiceServer = MockRestServiceServer.createServer(restTemplate); + member = entityManager.merge(member); } @DisplayName("로그아웃 성공 테스트") @@ -270,6 +276,7 @@ void search_my_info_success() throws Exception { member.changeDefaultSkintUrl(night); member.changeDefaultSkintUrl(morning); + memberRepository.flush(); // expected mockMvc.perform(get("/members")) @@ -281,8 +288,8 @@ void search_my_info_success() throws Exception { MockMvcResultMatchers.jsonPath("$.level").value(member.getTotalCertifyCount() / LEVEL_DIVISOR), MockMvcResultMatchers.jsonPath("$.exp").value(member.getTotalCertifyCount() % LEVEL_DIVISOR), - // MockMvcResultMatchers.jsonPath("$.birds.MORNING").value(morningInven.getItem().getImage()), - // MockMvcResultMatchers.jsonPath("$.birds.NIGHT").value(nightInven.getItem().getImage()), + MockMvcResultMatchers.jsonPath("$.birds.MORNING").value(morningInven.getItem().getImage()), + MockMvcResultMatchers.jsonPath("$.birds.NIGHT").value(nightInven.getItem().getImage()), MockMvcResultMatchers.jsonPath("$.badges[0].badge").value("MORNING_BIRTH"), MockMvcResultMatchers.jsonPath("$.badges[0].unlock").value(true), @@ -317,6 +324,11 @@ void search_my_info_with_no_badge_success() throws Exception { Inventory killerInven = InventoryFixture.inventory(member.getId(), killer); inventoryRepository.saveAll(List.of(nightInven, morningInven, killerInven)); + member.changeDefaultSkintUrl(night); + member.changeDefaultSkintUrl(morning); + + memberRepository.flush(); + // expected mockMvc.perform(get("/members")) .andExpect(status().isOk()) @@ -327,8 +339,8 @@ void search_my_info_with_no_badge_success() throws Exception { MockMvcResultMatchers.jsonPath("$.level").value(member.getTotalCertifyCount() / LEVEL_DIVISOR), MockMvcResultMatchers.jsonPath("$.exp").value(member.getTotalCertifyCount() % LEVEL_DIVISOR), - // MockMvcResultMatchers.jsonPath("$.birds.MORNING").value(morningInven.getItem().getImage()), - // MockMvcResultMatchers.jsonPath("$.birds.NIGHT").value(nightInven.getItem().getImage()), + MockMvcResultMatchers.jsonPath("$.birds.MORNING").value(morningInven.getItem().getImage()), + MockMvcResultMatchers.jsonPath("$.birds.NIGHT").value(nightInven.getItem().getImage()), MockMvcResultMatchers.jsonPath("$.badges[0].badge").value("MORNING_BIRTH"), MockMvcResultMatchers.jsonPath("$.badges[0].unlock").value(false), @@ -371,10 +383,11 @@ void search_friend_info_success() throws Exception { morningInven.select(); Inventory killerInven = InventoryFixture.inventory(friend.getId(), killer); + inventoryRepository.saveAll(List.of(nightInven, morningInven, killerInven)); + friend.changeDefaultSkintUrl(morning); friend.changeDefaultSkintUrl(night); memberRepository.flush(); - inventoryRepository.saveAll(List.of(nightInven, morningInven, killerInven)); // expected mockMvc.perform(get("/members/{memberId}", friend.getId())) From b721bc4f34835748ff5331bc952a279616301ce4 Mon Sep 17 00:00:00 2001 From: parksey Date: Tue, 28 Nov 2023 14:16:00 +0900 Subject: [PATCH 5/7] =?UTF-8?q?feat:=20=EC=84=9C=EB=B9=84=EC=8A=A4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/moabam/api/application/member/MemberService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/moabam/api/application/member/MemberService.java b/src/main/java/com/moabam/api/application/member/MemberService.java index b6505ce3..295a6186 100644 --- a/src/main/java/com/moabam/api/application/member/MemberService.java +++ b/src/main/java/com/moabam/api/application/member/MemberService.java @@ -107,7 +107,10 @@ private void validateNickname(String nickname) { private Member signUp(Long socialId) { Member member = MemberMapper.toMember(socialId); - return memberRepository.save(member); + Member savedMember = memberRepository.save(member); + saveMyEgg(savedMember); + + return savedMember; } private void saveMyEgg(Member member) { From 405b3939e367f2e079b2efc46a6cb282ed84df05 Mon Sep 17 00:00:00 2001 From: parksey Date: Tue, 28 Nov 2023 16:31:11 +0900 Subject: [PATCH 6/7] =?UTF-8?q?test:=20=EA=B8=B0=EB=B3=B8=20URL=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/moabam/global/common/util/BaseImageUrl.java | 6 +++--- .../moabam/api/application/member/MemberServiceTest.java | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/moabam/global/common/util/BaseImageUrl.java b/src/main/java/com/moabam/global/common/util/BaseImageUrl.java index ac66f717..c430933a 100644 --- a/src/main/java/com/moabam/global/common/util/BaseImageUrl.java +++ b/src/main/java/com/moabam/global/common/util/BaseImageUrl.java @@ -14,7 +14,7 @@ public class BaseImageUrl { public static final String DEFAULT_NIGHT_AWAKE_SKIN_URL = ""; public static final String DEFAULT_NIGHT_SLEEP_SKIN_URL = ""; - public static final String DEFAULT_MORNING_EGG_URL = "moabam/skins/오목눈이/기본/오목눈이알.png"; - public static final String DEFAULT_NIGHT_EGG_URL = "moabam/skins/부엉이/기본/부엉이알.png"; - public static final String MEMBER_PROFILE_URL = "moabam/default/기본회원프로필.png"; + public static final String DEFAULT_MORNING_EGG_URL = "moabam/skins/omok/default/egg.png"; + public static final String DEFAULT_NIGHT_EGG_URL = "moabam/skins/owl/default/egg.png"; + public static final String MEMBER_PROFILE_URL = "moabam/default/member-profile.png"; } diff --git a/src/test/java/com/moabam/api/application/member/MemberServiceTest.java b/src/test/java/com/moabam/api/application/member/MemberServiceTest.java index 3271f6f1..41febdbe 100644 --- a/src/test/java/com/moabam/api/application/member/MemberServiceTest.java +++ b/src/test/java/com/moabam/api/application/member/MemberServiceTest.java @@ -97,6 +97,8 @@ void signUp_success() { given(member.getId()).willReturn(1L); willReturn(member) .given(memberRepository).save(any(Member.class)); + willReturn(List.of(ItemFixture.morningSantaSkin().build(), ItemFixture.nightMageSkin())) + .given(itemRepository).findAllById(any()); // when LoginResponse result = memberService.login(authorizationTokenInfoResponse); @@ -213,5 +215,4 @@ void modify_success_test(@WithMember AuthMember authMember) { () -> assertThat(member.getProfileImage()).isEqualTo("/main") ); } - } From 7063372445f7155c24aa3af1c3e2e67b96fe6395 Mon Sep 17 00:00:00 2001 From: parksey Date: Tue, 28 Nov 2023 16:48:37 +0900 Subject: [PATCH 7/7] =?UTF-8?q?style:=20=EC=A4=91=EB=B3=B5=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/moabam/api/domain/member/Member.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/moabam/api/domain/member/Member.java b/src/main/java/com/moabam/api/domain/member/Member.java index e2bebc01..48486941 100644 --- a/src/main/java/com/moabam/api/domain/member/Member.java +++ b/src/main/java/com/moabam/api/domain/member/Member.java @@ -146,7 +146,6 @@ public void changeIntro(String intro) { public void changeProfileUri(String newProfileUri) { this.profileImage = requireNonNullElse(newProfileUri, profileImage); - this.profileImage = requireNonNullElse(newProfileUri, profileImage); } public void changeDefaultSkintUrl(Item item) throws NotFoundException {