diff --git a/backend/emm-sale/src/documentTest/java/com/emmsale/MemberApiTest.java b/backend/emm-sale/src/documentTest/java/com/emmsale/MemberApiTest.java index ea596c11d..4c8a172ea 100644 --- a/backend/emm-sale/src/documentTest/java/com/emmsale/MemberApiTest.java +++ b/backend/emm-sale/src/documentTest/java/com/emmsale/MemberApiTest.java @@ -252,7 +252,7 @@ void test_findProfile() throws Exception { void deleteMemberTest() throws Exception { //given final long memberId = 1L; - doNothing().when(memberUpdateService).deleteMember(any(), anyLong()); + doNothing().when(memberCommandService).deleteMember(any(), anyLong()); final String accessToken = "access_token"; //when @@ -272,7 +272,7 @@ void updateProfile() throws Exception { final String accessToken = "access_token"; final MockMultipartHttpServletRequestBuilder builder = createUpdateProfileBuilder(memberId); - when(memberUpdateService.updateMemberProfile + when(memberCommandService.updateMemberProfile (any(MultipartFile.class), anyLong(), any(Member.class))) .thenReturn(memberImageResponse); diff --git a/backend/emm-sale/src/documentTest/java/com/emmsale/MockMvcTestHelper.java b/backend/emm-sale/src/documentTest/java/com/emmsale/MockMvcTestHelper.java index 003ba7104..58ff5923b 100644 --- a/backend/emm-sale/src/documentTest/java/com/emmsale/MockMvcTestHelper.java +++ b/backend/emm-sale/src/documentTest/java/com/emmsale/MockMvcTestHelper.java @@ -18,7 +18,7 @@ import com.emmsale.member.application.InterestTagService; import com.emmsale.member.application.MemberActivityService; import com.emmsale.member.application.MemberQueryService; -import com.emmsale.member.application.MemberUpdateService; +import com.emmsale.member.application.MemberCommandService; import com.emmsale.message_room.application.MessageCommandService; import com.emmsale.message_room.application.RoomQueryService; import com.emmsale.notification.application.FcmTokenRegisterService; @@ -69,7 +69,7 @@ abstract class MockMvcTestHelper { @MockBean protected MemberActivityService memberActivityService; @MockBean - protected MemberUpdateService memberUpdateService; + protected MemberCommandService memberCommandService; @MockBean protected MemberQueryService memberQueryService; @MockBean diff --git a/backend/emm-sale/src/main/java/com/emmsale/member/api/MemberApi.java b/backend/emm-sale/src/main/java/com/emmsale/member/api/MemberApi.java index 15b465d2d..f39df0aea 100644 --- a/backend/emm-sale/src/main/java/com/emmsale/member/api/MemberApi.java +++ b/backend/emm-sale/src/main/java/com/emmsale/member/api/MemberApi.java @@ -1,18 +1,17 @@ package com.emmsale.member.api; -import com.emmsale.member.application.MemberActivityService; +import com.emmsale.member.application.MemberActivityCommandService; +import com.emmsale.member.application.MemberActivityQueryService; +import com.emmsale.member.application.MemberCommandService; import com.emmsale.member.application.MemberQueryService; -import com.emmsale.member.application.MemberUpdateService; import com.emmsale.member.application.dto.DescriptionRequest; import com.emmsale.member.application.dto.MemberActivityAddRequest; import com.emmsale.member.application.dto.MemberActivityInitialRequest; import com.emmsale.member.application.dto.MemberActivityResponses; import com.emmsale.member.application.dto.MemberImageResponse; import com.emmsale.member.application.dto.MemberProfileResponse; -import com.emmsale.member.application.dto.OpenProfileUrlRequest; import com.emmsale.member.domain.Member; import java.util.List; -import javax.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -32,8 +31,9 @@ @RequiredArgsConstructor public class MemberApi { - private final MemberActivityService memberActivityService; - private final MemberUpdateService memberUpdateService; + private final MemberActivityQueryService memberActivityQueryService; + private final MemberActivityCommandService memberActivityCommandService; + private final MemberCommandService memberCommandService; private final MemberQueryService memberQueryService; @PostMapping("/members") @@ -41,7 +41,7 @@ public ResponseEntity register( final Member member, @RequestBody final MemberActivityInitialRequest memberActivityInitialRequest ) { - memberActivityService.registerActivities(member, memberActivityInitialRequest); + memberActivityCommandService.registerActivities(member, memberActivityInitialRequest); return ResponseEntity.noContent().build(); } @@ -51,29 +51,20 @@ public ResponseEntity> addActivity( @RequestBody final MemberActivityAddRequest memberActivityAddRequest ) { return ResponseEntity.status(HttpStatus.CREATED) - .body(memberActivityService.addActivity(member, memberActivityAddRequest)); + .body(memberActivityCommandService.addActivity(member, memberActivityAddRequest)); } @DeleteMapping("/members/activities") public ResponseEntity> deleteActivity(final Member member, @RequestParam("activity-ids") final List deleteActivityIds) { return ResponseEntity.ok( - memberActivityService.deleteActivity(member, deleteActivityIds)); + memberActivityCommandService.deleteActivity(member, deleteActivityIds)); } @GetMapping("/members/{member-id}/activities") public ResponseEntity> findActivity( @PathVariable("member-id") final Long memberId) { - return ResponseEntity.ok(memberActivityService.findActivities(memberId)); - } - - @PutMapping("/members/open-profile-url") - public ResponseEntity updateOpenProfileUrl( - final Member member, - @RequestBody @Valid final OpenProfileUrlRequest openProfileUrlRequest - ) { - memberUpdateService.updateOpenProfileUrl(member, openProfileUrlRequest); - return ResponseEntity.noContent().build(); + return ResponseEntity.ok(memberActivityQueryService.findActivities(memberId)); } @PutMapping("/members/description") @@ -81,7 +72,7 @@ public ResponseEntity updateDescription( final Member member, @RequestBody final DescriptionRequest descriptionRequest ) { - memberUpdateService.updateDescription(member, descriptionRequest); + memberCommandService.updateDescription(member, descriptionRequest); return ResponseEntity.noContent().build(); } @@ -96,7 +87,7 @@ public ResponseEntity deleteMember( @PathVariable final Long memberId, final Member member ) { - memberUpdateService.deleteMember(member, memberId); + memberCommandService.deleteMember(member, memberId); return ResponseEntity.noContent().build(); } @@ -107,7 +98,7 @@ public ResponseEntity updateProfile( final Member member ) { final MemberImageResponse memberImageResponse - = memberUpdateService.updateMemberProfile(image, memberId, member); + = memberCommandService.updateMemberProfile(image, memberId, member); return ResponseEntity.ok(memberImageResponse); } } diff --git a/backend/emm-sale/src/main/java/com/emmsale/member/application/MemberUpdateService.java b/backend/emm-sale/src/main/java/com/emmsale/member/application/MemberCommandService.java similarity index 77% rename from backend/emm-sale/src/main/java/com/emmsale/member/application/MemberUpdateService.java rename to backend/emm-sale/src/main/java/com/emmsale/member/application/MemberCommandService.java index 5668771c6..0c1efbc51 100644 --- a/backend/emm-sale/src/main/java/com/emmsale/member/application/MemberUpdateService.java +++ b/backend/emm-sale/src/main/java/com/emmsale/member/application/MemberCommandService.java @@ -3,8 +3,6 @@ import com.emmsale.image.application.S3Client; import com.emmsale.member.application.dto.DescriptionRequest; import com.emmsale.member.application.dto.MemberImageResponse; -import com.emmsale.member.application.dto.MemberProfileResponse; -import com.emmsale.member.application.dto.OpenProfileUrlRequest; import com.emmsale.member.domain.Member; import com.emmsale.member.domain.MemberRepository; import com.emmsale.member.exception.MemberException; @@ -18,22 +16,11 @@ @Service @Transactional @RequiredArgsConstructor -public class MemberUpdateService { +public class MemberCommandService { private final MemberRepository memberRepository; private final S3Client s3Client; - public void updateOpenProfileUrl( - final Member member, - final OpenProfileUrlRequest openProfileUrlRequest - ) { - final Member persistMember = memberRepository.findById(member.getId()) - .orElseThrow(() -> new MemberException((MemberExceptionType.NOT_FOUND_MEMBER))); - final String openProfileUrl = openProfileUrlRequest.getOpenProfileUrl(); - - persistMember.updateOpenProfileUrl(openProfileUrl); - } - public void updateDescription(final Member member, final DescriptionRequest descriptionRequest) { final String description = descriptionRequest.getDescription(); diff --git a/backend/emm-sale/src/main/java/com/emmsale/member/domain/Member.java b/backend/emm-sale/src/main/java/com/emmsale/member/domain/Member.java index 314ccb927..51003a9d1 100644 --- a/backend/emm-sale/src/main/java/com/emmsale/member/domain/Member.java +++ b/backend/emm-sale/src/main/java/com/emmsale/member/domain/Member.java @@ -3,7 +3,6 @@ import com.emmsale.base.BaseEntity; import com.emmsale.member.exception.MemberException; import com.emmsale.member.exception.MemberExceptionType; -import java.util.Optional; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -30,9 +29,6 @@ public class Member extends BaseEntity { private String name; @Column(nullable = false) private String description; - @Column - @Getter(value = AccessLevel.PRIVATE) - private String openProfileUrl; @Column(nullable = false) private String imageUrl; @Column(nullable = false) @@ -59,10 +55,6 @@ public void updateName(final String name) { this.name = name; } - public void updateOpenProfileUrl(final String openProfileUrl) { - this.openProfileUrl = openProfileUrl; - } - public void updateDescription(final String description) { validateDescriptionNull(description); validateDescriptionLength(description); @@ -112,8 +104,4 @@ public boolean isOnboarded() { public boolean isNotGithubProfile() { return !imageUrl.startsWith(GITHUB_PROFILE_DOMAIN); } - - public Optional getOptionalOpenProfileUrl() { - return Optional.ofNullable(openProfileUrl); - } } diff --git a/backend/emm-sale/src/test/java/com/emmsale/member/application/MemberUpdateServiceTest.java b/backend/emm-sale/src/test/java/com/emmsale/member/application/MemberCommandServiceTest.java similarity index 83% rename from backend/emm-sale/src/test/java/com/emmsale/member/application/MemberUpdateServiceTest.java rename to backend/emm-sale/src/test/java/com/emmsale/member/application/MemberCommandServiceTest.java index a854c0ee2..d9a8495f4 100644 --- a/backend/emm-sale/src/test/java/com/emmsale/member/application/MemberUpdateServiceTest.java +++ b/backend/emm-sale/src/test/java/com/emmsale/member/application/MemberCommandServiceTest.java @@ -13,7 +13,6 @@ import com.emmsale.helper.ServiceIntegrationTestHelper; import com.emmsale.member.application.dto.DescriptionRequest; -import com.emmsale.member.application.dto.OpenProfileUrlRequest; import com.emmsale.member.domain.Member; import com.emmsale.member.domain.MemberRepository; import com.emmsale.member.exception.MemberException; @@ -32,31 +31,13 @@ import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.multipart.MultipartFile; -class MemberUpdateServiceTest extends ServiceIntegrationTestHelper { +class MemberCommandServiceTest extends ServiceIntegrationTestHelper { @Autowired - private MemberUpdateService memberUpdateService; + private MemberCommandService memberCommandService; @Autowired private MemberRepository memberRepository; - @Test - @DisplayName("오픈 프로필 URL을 업데이트한다.") - void updateOpenProfileUrlTest() { - // given - final Member member = memberRepository.save(memberFixture()); - - final String expectOpenProfileUrl = "https://open.kakao.com/new/profile/url"; - final OpenProfileUrlRequest request = new OpenProfileUrlRequest(expectOpenProfileUrl); - - // when - memberUpdateService.updateOpenProfileUrl(member, request); - - final Member actualMember = memberRepository.findById(member.getId()).get(); - - // then - assertThat(actualMember.getOptionalOpenProfileUrl().get()).isEqualTo(expectOpenProfileUrl); - } - @Nested @DisplayName("한줄 자기소개를 업데이트한다.") class UpdateDescription { @@ -72,7 +53,7 @@ void updateDescription_success(final String inputDescription) { final DescriptionRequest request = new DescriptionRequest(expectDescription); // when - memberUpdateService.updateDescription(member, request); + memberCommandService.updateDescription(member, request); final Member actualMember = memberRepository.findById(member.getId()).get(); @@ -90,7 +71,7 @@ void updateDescription_fail() { final DescriptionRequest request = new DescriptionRequest(invalidDescription); // when - final ThrowingCallable actual = () -> memberUpdateService.updateDescription(member, request); + final ThrowingCallable actual = () -> memberCommandService.updateDescription(member, request); // then assertThatThrownBy(actual) @@ -110,7 +91,7 @@ void updateDescription_trim(final String inputDescription) { final DescriptionRequest request = new DescriptionRequest(inputDescription); // when - memberUpdateService.updateDescription(member, request); + memberCommandService.updateDescription(member, request); final Member actualMember = memberRepository.findById(member.getId()).get(); @@ -131,7 +112,7 @@ void success() { final Member member = memberRepository.findById(memberId).get(); //when - memberUpdateService.deleteMember(member, memberId); + memberCommandService.deleteMember(member, memberId); //then assertThat(memberRepository.findById(memberId)) @@ -146,7 +127,7 @@ void forbbidenDeleteMemberException() { final Member member = memberRepository.findById(memberId).get(); //when && then - assertThatThrownBy(() -> memberUpdateService.deleteMember(member, otherMemberId)) + assertThatThrownBy(() -> memberCommandService.deleteMember(member, otherMemberId)) .isInstanceOf(MemberException.class) .hasMessage(MemberExceptionType.FORBIDDEN_DELETE_MEMBER.errorMessage()); } @@ -178,7 +159,7 @@ void pastGithubUrl() { final Member member = memberRepository.save(fixture); //when - memberUpdateService.updateMemberProfile(image, member.getId(), member); + memberCommandService.updateMemberProfile(image, member.getId(), member); //then assertAll( @@ -198,7 +179,7 @@ void pastCustomImage() { final Member member = memberRepository.save(fixture); //when - memberUpdateService.updateMemberProfile(image, member.getId(), member); + memberCommandService.updateMemberProfile(image, member.getId(), member); //then assertAll( @@ -219,7 +200,7 @@ void validateMemberIsNotMe() { //when && then final ThrowingCallable testTarget = () -> - memberUpdateService.updateMemberProfile(image, member.getId() + 1, member); + memberCommandService.updateMemberProfile(image, member.getId() + 1, member); assertThatThrownBy(testTarget) .isInstanceOf(MemberException.class) diff --git a/backend/emm-sale/src/test/java/com/emmsale/member/domain/MemberTest.java b/backend/emm-sale/src/test/java/com/emmsale/member/domain/MemberTest.java index 06b7532c5..f3b26d819 100644 --- a/backend/emm-sale/src/test/java/com/emmsale/member/domain/MemberTest.java +++ b/backend/emm-sale/src/test/java/com/emmsale/member/domain/MemberTest.java @@ -90,5 +90,4 @@ void trueCase() { assertTrue(member.isNotGithubProfile()); } } - }