From 3a9360938cc95a761dd92238fe2a4c5cc70fc345 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Tue, 6 Aug 2024 21:35:30 +0900 Subject: [PATCH 1/6] =?UTF-8?q?#452=20[feat]=20=EA=B4=80=EB=A6=AC=EC=9E=90?= =?UTF-8?q?=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=A9=A4=EB=B2=84=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20=EC=97=90=EB=9F=AC=20=EC=BD=94=EB=93=9C=20=EC=84=B8?= =?UTF-8?q?=EB=B6=84=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/mile/exception/message/ErrorMessage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module-common/src/main/java/com/mile/exception/message/ErrorMessage.java b/module-common/src/main/java/com/mile/exception/message/ErrorMessage.java index 886f9657..7372fd6b 100644 --- a/module-common/src/main/java/com/mile/exception/message/ErrorMessage.java +++ b/module-common/src/main/java/com/mile/exception/message/ErrorMessage.java @@ -22,7 +22,7 @@ public enum ErrorMessage { TOPIC_NOT_FOUND(40408, "해당 글감이 존재하지 않습니다."), KEYWORD_NOT_FOUND(40409, "해당 글모임의 글감 키워드가 존재하지 않습니다."), WRITERS_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "해당 모임의 작가가 요청한 개수 이상 존재하지 않습니다"), - WRITER_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "해당 작가는 존재하지 않습니다."), + WRITER_NOT_FOUND(40411, "해당 작가는 존재하지 않습니다."), RECOMMEND_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "추천 글감을 받아오는데 실패했습니다."), MOIM_TOPIC_NOT_FOUND(40413, "해당 모임의 글감이 존재하지 않습니다."), TOPIC_POST_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "해당 글감의 글이 존재하지 않습니다."), @@ -70,7 +70,7 @@ public enum ErrorMessage { USER_AUTHENTICATE_ERROR(40300, "해당 사용자는 모임에 접근 권한이 없습니다."), REPLY_USER_FORBIDDEN(40301, "사용자에게 해당 대댓글에 대한 권한이 없습니다."), WRITER_AUTHENTICATE_ERROR(40302, "해당 사용자는 글 생성/수정/삭제 권한이 없습니다."), - MOIM_OWNER_AUTHENTICATION_ERROR(HttpStatus.FORBIDDEN.value(), "사용자는 해당 모임의 모임장이 아닙니다."), + MOIM_OWNER_AUTHENTICATION_ERROR(40303, "사용자는 해당 모임의 모임장이 아닙니다."), WRITER_NAME_INFO_FORBIDDEN(HttpStatus.FORBIDDEN.value(), "해당 사용자는 필명에 접근 권한이 없습니다."), COMMENT_ACCESS_ERROR(40305, "해당 사용자는 댓글에 접근 권한이 없습니다."), /* From d13dfe800190e0b004cf2a18c1f759cc73fbc1e1 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Tue, 6 Aug 2024 21:36:13 +0900 Subject: [PATCH 2/6] =?UTF-8?q?#453=20[feat]=20=EA=B8=80=EB=AA=A8=EC=9E=84?= =?UTF-8?q?=20=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20=ED=94=8C=EB=A1=9C?= =?UTF-8?q?=EC=9A=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/mile/moim/service/MoimService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/module-domain/src/main/java/com/mile/moim/service/MoimService.java b/module-domain/src/main/java/com/mile/moim/service/MoimService.java index f577de34..a56bd9b8 100644 --- a/module-domain/src/main/java/com/mile/moim/service/MoimService.java +++ b/module-domain/src/main/java/com/mile/moim/service/MoimService.java @@ -225,8 +225,12 @@ public void modifyMoimInforation( final Long userId, final MoimInfoModifyRequest modifyRequest ) { - checkMoimNameUnique(modifyRequest.moimTitle()); Moim moim = moimRetriever.findById(moimId); + + if (!moim.getName().equals(modifyRequest.moimTitle())) { + validateMoimName(modifyRequest.moimTitle()); + } + moimRetriever.authenticateOwnerOfMoim(moim, userRetriever.findById(userId)); moim.modifyMoimInfo(modifyRequest); } From f58af99a8b7f0e40e15fecffc3e5d530126cfbcd Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Tue, 6 Aug 2024 21:36:37 +0900 Subject: [PATCH 3/6] =?UTF-8?q?#452=20[fix]=20jpql=20transactional=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/mile/topic/repository/TopicRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/module-domain/src/main/java/com/mile/topic/repository/TopicRepository.java b/module-domain/src/main/java/com/mile/topic/repository/TopicRepository.java index a63e3e36..1e4a5728 100644 --- a/module-domain/src/main/java/com/mile/topic/repository/TopicRepository.java +++ b/module-domain/src/main/java/com/mile/topic/repository/TopicRepository.java @@ -9,6 +9,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.lang.NonNull; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -22,6 +23,7 @@ public interface TopicRepository extends JpaRepository, TopicReposi Page findByMoimIdOrderByCreatedAtDesc(Long moimId, Pageable pageable); + @Transactional @Modifying @Query("DELETE FROM Topic t where t.moim = :moim") void deleteByMoim(@Param("moim") Moim moim); From 752015b7bca4576a95b07334cd8839025933a06b Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Tue, 6 Aug 2024 21:37:03 +0900 Subject: [PATCH 4/6] =?UTF-8?q?#452=20[refactor]=20Topic=20Remover=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/mile/topic/service/TopicRemover.java | 9 +-------- .../main/java/com/mile/topic/service/TopicService.java | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/module-domain/src/main/java/com/mile/topic/service/TopicRemover.java b/module-domain/src/main/java/com/mile/topic/service/TopicRemover.java index 00552c1c..ea08f73d 100644 --- a/module-domain/src/main/java/com/mile/topic/service/TopicRemover.java +++ b/module-domain/src/main/java/com/mile/topic/service/TopicRemover.java @@ -20,19 +20,12 @@ public class TopicRemover { private final TopicRepository topicRepository; public void deleteTopic( - final Topic topic, - final User user + final Topic topic ) { deletePostsOfTopic(topic); topicRepository.deleteById(topic.getId()); } - public void deleteTopics( - final List topics - ) { - - } - private void deletePostsOfTopic( final Topic topic ) { diff --git a/module-domain/src/main/java/com/mile/topic/service/TopicService.java b/module-domain/src/main/java/com/mile/topic/service/TopicService.java index 2c4a3d45..8456977e 100644 --- a/module-domain/src/main/java/com/mile/topic/service/TopicService.java +++ b/module-domain/src/main/java/com/mile/topic/service/TopicService.java @@ -82,7 +82,7 @@ public void deleteTopic( User user = userService.findById(userId); topicRetriever.authenticateTopicWithUser(topic, user); topicRetriever.checkSingleTopicDeletion(topic); - topicRemover.deleteTopic(topic, user); + topicRemover.deleteTopic(topic); } public void putTopic( From 8c0101d907a5ef6519ab8f01d1be39a0555c6948 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Wed, 7 Aug 2024 00:43:23 +0900 Subject: [PATCH 5/6] =?UTF-8?q?#452=20[refactor]=20=EB=AF=B8=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mile/topic/service/TopicService.java | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/module-domain/src/main/java/com/mile/topic/service/TopicService.java b/module-domain/src/main/java/com/mile/topic/service/TopicService.java index 8456977e..98084a60 100644 --- a/module-domain/src/main/java/com/mile/topic/service/TopicService.java +++ b/module-domain/src/main/java/com/mile/topic/service/TopicService.java @@ -27,7 +27,6 @@ public class TopicService { private final TopicCreator topicCreator; private final UserService userService; - public List getContentsWithIsSelectedFromMoim( final Long moimId, final Long selectedTopicId @@ -42,23 +41,6 @@ public PostListInTopicResponse getPostListByTopic( return topicRetriever.getPostListByTopic(topicId, lastPostId); } - public MoimTopicInfoListResponse getTopicListFromMoim( - final Long moimId, - final int page - ) { - return topicRetriever.getTopicListFromMoim(moimId, page); - } - - public MoimTopicInfoListResponse getTopicResponsesFromPage(Page topicPage, final Long moimId) { - return topicRetriever.getTopicResponsesFromPage(topicPage, moimId); - } - - public Long getNumberOfTopicFromMoim( - final Long moimId - ) { - return topicRetriever.getNumberOfTopicFromMoim(moimId); - } - public TopicDetailResponse getTopicDetail( final Long userId, final Long topicId @@ -66,13 +48,6 @@ public TopicDetailResponse getTopicDetail( return topicRetriever.getTopicDetail(userId, topicId); } - public Long createTopicOfMoim( - final Moim moim, - final TopicCreateRequest createRequest - ) { - return topicCreator.createTopicOfMoim(moim, createRequest); - } - @Transactional public void deleteTopic( final Long userId, From 6b12d30cf7d0a78b5b4f0ed444f4a7100ddec76c Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Wed, 7 Aug 2024 00:44:00 +0900 Subject: [PATCH 6/6] =?UTF-8?q?#452=20[test]=20=EA=B8=80=EB=AA=A8=EC=9E=84?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=20=ED=94=8C=EB=A1=9C=EC=9A=B0=20=EC=9D=B8?= =?UTF-8?q?=EC=88=98=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 전체 플로우 (글모임 등록 -> 글감 등록 -> 글 작성) 후 제거 테스트 진행했습니다! --- .../com/mile/controller/MoimControllerTest.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/module-api/src/test/java/com/mile/controller/MoimControllerTest.java b/module-api/src/test/java/com/mile/controller/MoimControllerTest.java index 5d18e818..89727cdf 100644 --- a/module-api/src/test/java/com/mile/controller/MoimControllerTest.java +++ b/module-api/src/test/java/com/mile/controller/MoimControllerTest.java @@ -9,6 +9,8 @@ import com.mile.moim.service.dto.MoimInfoModifyRequest; import com.mile.moim.service.dto.TopicCreateRequest; import com.mile.moim.service.dto.WriterMemberJoinRequest; +import com.mile.post.service.PostService; +import com.mile.post.service.dto.PostCreateRequest; import com.mile.user.domain.User; import com.mile.user.repository.UserRepository; import com.mile.utils.SecureUrlUtil; @@ -54,6 +56,9 @@ public class MoimControllerTest { @Autowired private MoimService moimService; + @Autowired + private PostService postService; + @Autowired private ObjectMapper objectMapper; @@ -81,6 +86,7 @@ public void aTestForDummyUser() throws JsonProcessingException { 테스트 이전 더미 모임 쌓기 */ @Test + @Transactional @DisplayName("더미 모임 생성") public void bSaveNewMoimAndGetMoimId() { String randomTagString = UUID.randomUUID().toString().substring(0, 3); @@ -95,7 +101,13 @@ public void bSaveNewMoimAndGetMoimId() { randomTagString, randomString ); + + TopicCreateRequest topicCreateRequest = new TopicCreateRequest(randomString, randomTagString, randomTagString); MOIM_ID = moimService.createMoim(USER_ID, createRequest).moimId(); + String topicId = secureUrlUtil + .encodeUrl(Long.parseLong(moimService.createTopic(secureUrlUtil.decodeUrl(MOIM_ID), USER_ID, topicCreateRequest))); + PostCreateRequest postCreateRequest =new PostCreateRequest(MOIM_ID, topicId, randomString, randomString, randomString, false); + postService.createPost(USER_ID, postCreateRequest); } /* @@ -435,7 +447,6 @@ public void createTopicTest() throws Exception { @Test @DisplayName("글모임이 정상적으로 삭제된다.") - @Transactional public void zdeleteMoimTest() throws Exception { //given String token = "Bearer " + jwtTokenProvider.issueAccessToken(USER_ID);