From aaab59a0f239d24bfc40249936477460437693ae Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Mon, 25 Mar 2024 22:54:06 +0900 Subject: [PATCH 01/21] =?UTF-8?q?#257=20[feat]=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EB=B0=8F=20swagger=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mile/controller/moim/MoimController.java | 13 +++++++++++++ .../controller/moim/MoimControllerSwagger.java | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/module-api/src/main/java/com/mile/controller/moim/MoimController.java b/module-api/src/main/java/com/mile/controller/moim/MoimController.java index 7a627e8d..c2f3d412 100644 --- a/module-api/src/main/java/com/mile/controller/moim/MoimController.java +++ b/module-api/src/main/java/com/mile/controller/moim/MoimController.java @@ -9,6 +9,7 @@ import com.mile.moim.service.dto.MoimAuthenticateResponse; import com.mile.moim.service.dto.MoimCuriousPostListResponse; import com.mile.moim.service.dto.MoimInfoResponse; +import com.mile.moim.service.dto.MoimTopicInfoListResponse; import com.mile.moim.service.dto.MoimTopicResponse; import com.mile.moim.service.dto.PopularWriterListResponse; import com.mile.moim.service.dto.TemporaryPostExistResponse; @@ -136,4 +137,16 @@ public SuccessResponse getTemporaryPost( ) { return SuccessResponse.of(SuccessMessage.IS_TEMPORARY_POST_EXIST_GET_SUCCESS, moimService.getTemporaryPost(moimId, principalHandler.getUserIdFromPrincipal())); } + + @Override + @GetMapping("/{moimId}/admin/topicList") + public ResponseEntity> getMoimTopicList( + @MoimIdPathVariable final Long moimId, + @RequestParam final Long page, + @PathVariable("moimId") final String moimUrl + ) { + return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_TOPIC_LIST_GET_SUCCESS, moimService.getMoimTopicList(moimId, principalHandler.getUserIdFromPrincipal(), page))); + } + + } diff --git a/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java b/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java index 9b29f33f..35af03a4 100644 --- a/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java +++ b/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java @@ -6,6 +6,7 @@ import com.mile.moim.service.dto.ContentListResponse; import com.mile.moim.service.dto.MoimCuriousPostListResponse; import com.mile.moim.service.dto.MoimInfoResponse; +import com.mile.moim.service.dto.MoimTopicInfoListResponse; import com.mile.moim.service.dto.MoimTopicResponse; import com.mile.moim.service.dto.TemporaryPostExistResponse; import com.mile.moim.service.dto.TopicListResponse; @@ -192,4 +193,21 @@ ResponseEntity joinMoim( @RequestBody final WriterMemberJoinRequest joinRequest, @PathVariable("moimId") final String moimUrl ); + + @Operation(summary = "관리자 페이지 글감 조회") + @ApiResponses( + value = { + @ApiResponse(responseCode = "200", description = "글감 리스트 조회가 완료되었습니다."), + @ApiResponse(responseCode = "404", description = "해당 모임은 존재하지 않습니다."), + @ApiResponse(responseCode = "403", description = "사용자는 해당 모임의 모임장이 아닙니다."), + @ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + } + ) + ResponseEntity> getMoimTopicList( + @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId, + final Long page, + @PathVariable("moimId") final String moimUrl + ); + } From 0557d29a7d70a1063b10056b16a5ed2b19e6e7d0 Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Mon, 25 Mar 2024 22:54:44 +0900 Subject: [PATCH 02/21] =?UTF-8?q?#257=20[feat]=20=EB=AA=A8=EC=9E=84?= =?UTF-8?q?=EC=9E=A5=20=ED=99=95=EC=9D=B8=20=EB=B0=8F=20=EA=B8=80=EA=B0=90?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mile/moim/service/MoimService.java | 25 +++++++++++++++++-- .../com/mile/topic/service/TopicService.java | 12 +++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) 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 f8f4d7bb..5f1d064c 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 @@ -10,6 +10,7 @@ import com.mile.moim.service.dto.MoimAuthenticateResponse; import com.mile.moim.service.dto.MoimCuriousPostListResponse; import com.mile.moim.service.dto.MoimInfoResponse; +import com.mile.moim.service.dto.MoimTopicInfoListResponse; import com.mile.moim.service.dto.MoimTopicResponse; import com.mile.moim.service.dto.TemporaryPostExistResponse; import com.mile.moim.service.dto.TopicListResponse; @@ -33,8 +34,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import java.time.LocalDateTime; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -158,4 +157,26 @@ public TemporaryPostExistResponse getTemporaryPost( String postId = postCreateService.getTemporaryPostExist(findById(moimId), writerNameService.findByWriterId(userId)); return TemporaryPostExistResponse.of(!secureUrlUtil.decodeUrl(postId).equals(0L), postId); } + + public MoimTopicInfoListResponse getMoimTopicList( + final Long moimId, + final Long userId, + final Long page + ) { + // 모임장인지 확인하기 + getAuthenticateOwnerOfMoim(moimId, userId); + return MoimTopicInfoListResponse.of(topicService.getTopicListFromMoim(moimId)); + } + + private void getAuthenticateOwnerOfMoim( + final Long moimId, + final Long userId + ) { + Long writerNameId = writerNameService.getWriterNameIdByMoimIdAndUserId(moimId, userId); + Moim moim = findById(moimId); + if (!moim.getOwner().getId().equals(writerNameId)) { + throw new ForbiddenException(ErrorMessage.OWNER_AUTHENTICATE_ERROR); + } + } + } 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 0a013893..9064431c 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 @@ -5,6 +5,7 @@ import com.mile.exception.message.ErrorMessage; import com.mile.exception.model.NotFoundException; import com.mile.moim.domain.Moim; +import com.mile.moim.service.dto.MoimTopicInfoResponse; import com.mile.post.service.PostGetService; import com.mile.post.service.dto.PostListResponse; import com.mile.topic.domain.Topic; @@ -120,4 +121,15 @@ public PostListInTopicResponse getPostListByTopic( return PostListInTopicResponse.of(TopicOfMoimResponse.of(topic), postGetService.findByTopic(topic).stream().map(p -> PostListResponse.of(p, commentService.findCommentCountByPost(p))).collect(Collectors.toList())); } + + public List getTopicListFromMoim( + final Long moimId + ) { + List topicList = sortByCreatedAt(findTopicListByMoimId(moimId)); + isContentsEmpty(topicList); + return topicList + .stream() + .map(MoimTopicInfoResponse::of) + .collect(Collectors.toList()); + } } From 259429b46358d263ad0130fda7361b2d9be3f47d Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Mon, 25 Mar 2024 22:55:07 +0900 Subject: [PATCH 03/21] =?UTF-8?q?#257=20[feat]=20=EC=97=90=EB=9F=AC,=20?= =?UTF-8?q?=EC=84=B1=EA=B3=B5=20=EB=A9=94=EC=8B=9C=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/mile/exception/message/ErrorMessage.java | 4 +--- .../main/java/com/mile/exception/message/SuccessMessage.java | 1 + 2 files changed, 2 insertions(+), 3 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 6544f346..9e03e6d0 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 @@ -62,10 +62,8 @@ public enum ErrorMessage { */ USER_AUTHENTICATE_ERROR(HttpStatus.FORBIDDEN.value(), "해당 사용자는 모임에 접근 권한이 없습니다."), WRITER_AUTHENTICATE_ERROR(HttpStatus.FORBIDDEN.value(), "해당 사용자는 글 생성/수정/삭제 권한이 없습니다."), - /* - Forbidden - */ COMMENT_ACCESS_ERROR(HttpStatus.FORBIDDEN.value(), "해당 사용자는 댓글에 접근 권한이 없습니다."), + OWNER_AUTHENTICATE_ERROR(HttpStatus.FORBIDDEN.value(), "사용자는 해당 모임의 모임장이 아닙니다."), /* Method Not Supported */ diff --git a/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java b/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java index 8c69cfa2..267bef59 100644 --- a/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java +++ b/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java @@ -34,6 +34,7 @@ public enum SuccessMessage { BEST_MOIM_POSTS_GET_SUCCESS(HttpStatus.OK.value(), "베스트 활동 모임과 글 조회가 완료되었습니다."), IS_TEMPORARY_POST_EXIST_GET_SUCCESS(HttpStatus.OK.value(), "임시저장 글 존재 여부 조회가 완료되었습니다."), IS_CONFLICT_WRITER_NAME_GET_SUCCESS(HttpStatus.OK.value(), "댓글 중복 여부가 조회되었습니다."), + MOIM_TOPIC_LIST_GET_SUCCESS(HttpStatus.OK.value(), "글감 리스트 조회가 완료되었습니다."), /* 201 CREATED */ From 8ca6e24a80240276d5a29405a44e23ece3081de8 Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Mon, 25 Mar 2024 22:55:31 +0900 Subject: [PATCH 04/21] =?UTF-8?q?#257=20[feat]=20DTO=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/MoimTopicInfoListResponse.java | 17 +++++++++++++ .../service/dto/MoimTopicInfoResponse.java | 24 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoListResponse.java create mode 100644 module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoResponse.java diff --git a/module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoListResponse.java b/module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoListResponse.java new file mode 100644 index 00000000..c1ec083f --- /dev/null +++ b/module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoListResponse.java @@ -0,0 +1,17 @@ +package com.mile.moim.service.dto; + +import java.util.List; + +public record MoimTopicInfoListResponse( + int topicCount, + List topics +) { + public static MoimTopicInfoListResponse of ( + final List moimTopicInfoResponses + ) { + return new MoimTopicInfoListResponse( + moimTopicInfoResponses.size(), + moimTopicInfoResponses + ); + } +} diff --git a/module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoResponse.java b/module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoResponse.java new file mode 100644 index 00000000..23725ff4 --- /dev/null +++ b/module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoResponse.java @@ -0,0 +1,24 @@ +package com.mile.moim.service.dto; + +import com.mile.topic.domain.Topic; +import com.mile.utils.DateUtil; + +public record MoimTopicInfoResponse( + String topicId, + String topicName, + String topicTag, + String topicDescription, + String createdAt +) { + public static MoimTopicInfoResponse of( + final Topic topic + ) { + return new MoimTopicInfoResponse( + topic.getIdUrl(), + topic.getContent(), + topic.getKeyword(), + topic.getDescription(), + DateUtil.getStringDateOfLocalDate(topic.getCreatedAt()) + ); + } +} From 6832bc25e6c80099ce555663c01fb98ddbaaeba3 Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Tue, 26 Mar 2024 23:13:19 +0900 Subject: [PATCH 05/21] =?UTF-8?q?#260=20[feat]=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mile/controller/moim/MoimController.java | 13 +++++++++++++ .../controller/moim/MoimControllerSwagger.java | 16 ++++++++++++++++ .../mile/exception/message/SuccessMessage.java | 1 + 3 files changed, 30 insertions(+) diff --git a/module-api/src/main/java/com/mile/controller/moim/MoimController.java b/module-api/src/main/java/com/mile/controller/moim/MoimController.java index e914bc0c..0393b59f 100644 --- a/module-api/src/main/java/com/mile/controller/moim/MoimController.java +++ b/module-api/src/main/java/com/mile/controller/moim/MoimController.java @@ -17,12 +17,16 @@ import com.mile.moim.service.dto.WriterNameConflictCheckResponse; import com.mile.moim.service.dto.WriterMemberJoinRequest; import com.mile.resolver.moim.MoimIdPathVariable; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -146,4 +150,13 @@ public SuccessResponse getTemporaryPost( ) { return SuccessResponse.of(SuccessMessage.IS_TEMPORARY_POST_EXIST_GET_SUCCESS, moimService.getTemporaryPost(moimId, principalHandler.getUserIdFromPrincipal())); } + + @Override + @PutMapping("/{moimId}/topic/{topicId}") + public ResponseEntity putTopic( + @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId, + @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long topicId + ) { + return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.TOPIC_PUT_SUCCESS)); + } } diff --git a/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java b/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java index 5efe452b..6458e721 100644 --- a/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java +++ b/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java @@ -207,4 +207,20 @@ ResponseEntity joinMoim( @RequestBody final WriterMemberJoinRequest joinRequest, @PathVariable("moimId") final String moimUrl ); + + @Operation(summary = "글모임 글감 수정") + @ApiResponses( + value = { + @ApiResponse(responseCode = "200", description = "글감 수정이 완료되었습니다."), + @ApiResponse(responseCode = "400", description = "입력 값이 유효하지 않습니다."), + @ApiResponse(responseCode = "403", description = "사용자는 해당 모임의 모임장이 아닙니다."), + @ApiResponse(responseCode = "404", description = "해당 모임은 존재하지 않습니다."), + @ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + } + ) + ResponseEntity putTopic( + @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId, + @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long topicId + ); } diff --git a/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java b/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java index f96c132e..8da8d798 100644 --- a/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java +++ b/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java @@ -35,6 +35,7 @@ public enum SuccessMessage { IS_TEMPORARY_POST_EXIST_GET_SUCCESS(HttpStatus.OK.value(), "임시저장 글 존재 여부 조회가 완료되었습니다."), MOIM_INVITE_INFO_GET_SUCCESS(HttpStatus.OK.value(), "모임의 초대 정보 조회가 완료되었습니다."), IS_CONFLICT_WRITER_NAME_GET_SUCCESS(HttpStatus.OK.value(), "댓글 중복 여부가 조회되었습니다."), + TOPIC_PUT_SUCCESS(HttpStatus.OK.value(), "글감 수정이 완료되었습니다."), /* 201 CREATED */ From f3c2deea53ecde8407744d3890be0b88991d5995 Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Wed, 27 Mar 2024 01:01:22 +0900 Subject: [PATCH 06/21] =?UTF-8?q?#258=20[refactor]=20=EC=B4=9D=20=EA=B8=80?= =?UTF-8?q?=EA=B0=90=20=EC=88=98=20=EC=A1=B0=ED=9A=8C=EC=99=80=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=82=B4=20=EA=B8=80=EA=B0=90=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/mile/controller/moim/MoimController.java | 2 +- .../com/mile/controller/moim/MoimControllerSwagger.java | 2 +- .../src/main/java/com/mile/moim/service/MoimService.java | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/module-api/src/main/java/com/mile/controller/moim/MoimController.java b/module-api/src/main/java/com/mile/controller/moim/MoimController.java index 0c0d7f98..3d011e66 100644 --- a/module-api/src/main/java/com/mile/controller/moim/MoimController.java +++ b/module-api/src/main/java/com/mile/controller/moim/MoimController.java @@ -153,7 +153,7 @@ public SuccessResponse getTemporaryPost( @GetMapping("/{moimId}/admin/topicList") public ResponseEntity> getMoimTopicList( @MoimIdPathVariable final Long moimId, - @RequestParam final Long page, + @RequestParam final int page, @PathVariable("moimId") final String moimUrl ) { return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_TOPIC_LIST_GET_SUCCESS, moimService.getMoimTopicList(moimId, principalHandler.getUserIdFromPrincipal(), page))); diff --git a/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java b/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java index d65137ed..c7fdd868 100644 --- a/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java +++ b/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java @@ -223,7 +223,7 @@ ResponseEntity joinMoim( ) ResponseEntity> getMoimTopicList( @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId, - final Long page, + final int page, @PathVariable("moimId") final String moimUrl ); 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 097204d3..ea47b3a9 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 @@ -30,7 +30,6 @@ import com.mile.writername.domain.WriterName; import com.mile.writername.service.WriterNameService; import com.mile.moim.service.dto.PopularWriterListResponse; - import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; @@ -169,11 +168,10 @@ public TemporaryPostExistResponse getTemporaryPost( public MoimTopicInfoListResponse getMoimTopicList( final Long moimId, final Long userId, - final Long page + final int page ) { - // 모임장인지 확인하기 getAuthenticateOwnerOfMoim(moimId, userId); - return MoimTopicInfoListResponse.of(topicService.getTopicListFromMoim(moimId)); + return MoimTopicInfoListResponse.of(topicService.getNumberOfTopicFromMoim(moimId), topicService.getTopicListFromMoim(moimId, page)); } private void getAuthenticateOwnerOfMoim( From 7a7f8a93a5b76c02a2bc59bde56cef60516d3922 Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Wed, 27 Mar 2024 01:06:37 +0900 Subject: [PATCH 07/21] =?UTF-8?q?#257=20[refactor]=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=EB=84=A4=EC=9D=B4=EC=85=98=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/MoimTopicInfoListResponse.java | 5 ++-- .../topic/repository/TopicRepository.java | 5 +++- .../com/mile/topic/service/TopicService.java | 24 +++++++++++++++---- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoListResponse.java b/module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoListResponse.java index c1ec083f..602db898 100644 --- a/module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoListResponse.java +++ b/module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoListResponse.java @@ -3,14 +3,15 @@ import java.util.List; public record MoimTopicInfoListResponse( - int topicCount, + Long topicCount, List topics ) { public static MoimTopicInfoListResponse of ( + final Long topicCount, final List moimTopicInfoResponses ) { return new MoimTopicInfoListResponse( - moimTopicInfoResponses.size(), + topicCount, moimTopicInfoResponses ); } 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 6da99fd6..410dacb4 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 @@ -1,5 +1,6 @@ package com.mile.topic.repository; - +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import com.mile.topic.domain.Topic; import org.springframework.data.jpa.repository.JpaRepository; @@ -8,4 +9,6 @@ public interface TopicRepository extends JpaRepository, TopicRepositoryCustom { List findByMoimId(final Long moimId); + Page findByMoimIdOrderByCreatedAtDesc(Long moimId, Pageable pageable); + Long countByMoimId(final Long moimId); } 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 9064431c..fb63ed6b 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 @@ -16,6 +16,9 @@ import com.mile.topic.service.dto.TopicOfMoimResponse; import com.mile.topic.service.dto.TopicResponse; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import java.util.Comparator; @@ -26,6 +29,8 @@ @RequiredArgsConstructor public class TopicService { + private static final int TOPIC_PER_PAGE_SIZE = 4; + private final TopicRepository topicRepository; private final CommentService commentService; private final PostGetService postGetService; @@ -123,13 +128,24 @@ public PostListInTopicResponse getPostListByTopic( } public List getTopicListFromMoim( - final Long moimId + final Long moimId, + final int page ) { - List topicList = sortByCreatedAt(findTopicListByMoimId(moimId)); - isContentsEmpty(topicList); - return topicList + + PageRequest pageRequest = PageRequest.of(page-1, TOPIC_PER_PAGE_SIZE, Sort.by(Sort.Direction.DESC, "createdAt")); + Page topicPage = topicRepository.findByMoimIdOrderByCreatedAtDesc(moimId, pageRequest); + + isContentsEmpty(topicPage.getContent()); + + return topicPage.getContent() .stream() .map(MoimTopicInfoResponse::of) .collect(Collectors.toList()); } + + public Long getNumberOfTopicFromMoim( + final Long moimId + ) { + return topicRepository.countByMoimId(moimId); + } } From c3d2a174679f062de99e2eaa04d2c03335243eca Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Wed, 27 Mar 2024 19:01:04 +0900 Subject: [PATCH 08/21] =?UTF-8?q?#271=20[feat]=20=EB=A9=A4=EB=B2=84=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../writername/WriterNameController.java | 30 +++++++++++++++++++ .../WriterNameControllerSwagger.java | 30 +++++++++++++++++++ .../exception/message/SuccessMessage.java | 1 + 3 files changed, 61 insertions(+) create mode 100644 module-api/src/main/java/com/mile/controller/writername/WriterNameController.java create mode 100644 module-api/src/main/java/com/mile/controller/writername/WriterNameControllerSwagger.java diff --git a/module-api/src/main/java/com/mile/controller/writername/WriterNameController.java b/module-api/src/main/java/com/mile/controller/writername/WriterNameController.java new file mode 100644 index 00000000..cd52f510 --- /dev/null +++ b/module-api/src/main/java/com/mile/controller/writername/WriterNameController.java @@ -0,0 +1,30 @@ +package com.mile.controller.writername; + +import com.mile.authentication.PrincipalHandler; +import com.mile.dto.SuccessResponse; +import com.mile.exception.message.SuccessMessage; +import com.mile.writername.service.WriterNameDeleteService; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RequiredArgsConstructor +@RestController +@RequestMapping("/api/writerName") +public class WriterNameController implements WriterNameControllerSwagger{ + + private final WriterNameDeleteService writerNameDeleteService; + private final PrincipalHandler principalHandler; + + @Override + @DeleteMapping("/{writerNameId}") + public ResponseEntity deleteMember( + @PathVariable("writerNameId") final Long writerNameId + ) { + writerNameDeleteService.deleteWriterNameById(writerNameId, principalHandler.getUserIdFromPrincipal()); + return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_MEMBER_DELETE_SUCCESS)); + } +} diff --git a/module-api/src/main/java/com/mile/controller/writername/WriterNameControllerSwagger.java b/module-api/src/main/java/com/mile/controller/writername/WriterNameControllerSwagger.java new file mode 100644 index 00000000..6dc146cc --- /dev/null +++ b/module-api/src/main/java/com/mile/controller/writername/WriterNameControllerSwagger.java @@ -0,0 +1,30 @@ +package com.mile.controller.writername; + +import com.mile.dto.ErrorResponse; +import com.mile.dto.SuccessResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; + +@Tag(name = "WriterName") +public interface WriterNameControllerSwagger { + + @Operation(summary = "관리자 페이지 멤버 삭제") + @ApiResponses( + value = { + @ApiResponse(responseCode = "200", description = "멤버 삭제가 완료되었습니다."), + @ApiResponse(responseCode = "404", description = "해당 모임은 존재하지 않습니다."), + @ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + } + ) + ResponseEntity deleteMember( + @PathVariable("writerNameId") final Long writerNameId + ); +} + diff --git a/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java b/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java index 188b3078..1b817b76 100644 --- a/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java +++ b/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java @@ -37,6 +37,7 @@ public enum SuccessMessage { IS_CONFLICT_WRITER_NAME_GET_SUCCESS(HttpStatus.OK.value(), "댓글 중복 여부가 조회되었습니다."), MOIM_INFORMATION_PUT_SUCCESS(HttpStatus.OK.value(), "모임 정보 수정이 완료되었습니다."), IS_CONFLICT_MOIM_NAME_GET_SUCCESS(HttpStatus.OK.value(), "글모임 이름 중복 확인이 완료되었습니다."), + MOIM_MEMBER_DELETE_SUCCESS(HttpStatus.OK.value(), "멤버 삭제가 완료되었습니다."), /* 201 CREATED */ From 30399008375774fe6657c430adbe918b664ffe6a Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Wed, 27 Mar 2024 19:01:14 +0900 Subject: [PATCH 09/21] =?UTF-8?q?#271=20[feat]=20=EB=A9=A4=EB=B2=84=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/WriterNameDeleteService.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 module-domain/src/main/java/com/mile/writername/service/WriterNameDeleteService.java diff --git a/module-domain/src/main/java/com/mile/writername/service/WriterNameDeleteService.java b/module-domain/src/main/java/com/mile/writername/service/WriterNameDeleteService.java new file mode 100644 index 00000000..d6f69611 --- /dev/null +++ b/module-domain/src/main/java/com/mile/writername/service/WriterNameDeleteService.java @@ -0,0 +1,37 @@ +package com.mile.writername.service; + +import com.mile.exception.message.ErrorMessage; +import com.mile.exception.model.NotFoundException; +import com.mile.moim.service.MoimService; +import com.mile.writername.domain.WriterName; +import com.mile.writername.repository.WriterNameRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +public class WriterNameDeleteService { + + private final WriterNameRepository writerNameRepository; + private final MoimService moimService; + + @Transactional + public void deleteWriterNameById( + final Long writerNameId, + final Long userId + ) { + WriterName writerName = findById(writerNameId); + moimService.authenticateOwnerOfMoim(writerName.getMoim(), userId); + writerNameRepository.delete(writerName); + } + + private WriterName findById( + final Long writerNameId + ) { + WriterName writerName = writerNameRepository.findById(writerNameId).orElseThrow( + () -> new NotFoundException(ErrorMessage.WRITER_NOT_FOUND) + ); + return writerName; + } +} From 0ebd153f488f1437df9a1a47b4b30a2836707952 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Thu, 28 Mar 2024 09:06:29 +0900 Subject: [PATCH 10/21] =?UTF-8?q?#263=20[feat]=20=EA=B8=80=EA=B0=90=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EA=B4=80=EB=A0=A8=20=EB=B8=8C=EB=9E=9C?= =?UTF-8?q?=EC=B9=98=20=EC=9E=AC=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mile/controller/moim/MoimController.java | 11 ++++++++ .../moim/MoimControllerSwagger.java | 26 +++++++++++++++++ .../exception/message/SuccessMessage.java | 1 + .../com/mile/moim/service/MoimService.java | 12 ++++++++ .../moim/service/dto/TopicCreateRequest.java | 18 ++++++++++++ .../java/com/mile/topic/domain/Topic.java | 28 +++++++++++++++++++ .../com/mile/topic/service/TopicService.java | 14 ++++++++++ 7 files changed, 110 insertions(+) create mode 100644 module-domain/src/main/java/com/mile/moim/service/dto/TopicCreateRequest.java diff --git a/module-api/src/main/java/com/mile/controller/moim/MoimController.java b/module-api/src/main/java/com/mile/controller/moim/MoimController.java index 9ba950a7..bfe8e01e 100644 --- a/module-api/src/main/java/com/mile/controller/moim/MoimController.java +++ b/module-api/src/main/java/com/mile/controller/moim/MoimController.java @@ -15,6 +15,7 @@ import com.mile.moim.service.dto.MoimTopicResponse; import com.mile.moim.service.dto.PopularWriterListResponse; import com.mile.moim.service.dto.TemporaryPostExistResponse; +import com.mile.moim.service.dto.TopicCreateRequest; import com.mile.moim.service.dto.TopicListResponse; import com.mile.moim.service.dto.WriterNameConflictCheckResponse; import com.mile.moim.service.dto.WriterMemberJoinRequest; @@ -136,6 +137,16 @@ public SuccessResponse getMostCuriousPostByMoim( return SuccessResponse.of(SuccessMessage.MOIM_TOP_2_POST_GET_SUCCESS, moimService.getMostCuriousPostFromMoim(moimId)); } + @Override + @PostMapping("/{moimId}/topic") + public ResponseEntity createTopicOfMoim( + @MoimIdPathVariable final Long moimId, + @RequestBody final TopicCreateRequest createRequest, + @PathVariable("moimId") final String moimUrl + ) { + return ResponseEntity.created(URI.create(moimService.createTopic(moimId,principalHandler.getUserIdFromPrincipal(), createRequest))).body(SuccessResponse.of(SuccessMessage.TOPIC_CREATE_SUCCESS)); + } + @GetMapping("/best") public ResponseEntity> getBestMoimAndPostList() { return ResponseEntity.status(HttpStatus.OK).body(SuccessResponse.of(SuccessMessage.BEST_MOIM_POSTS_GET_SUCCESS, moimService.getBestMoimAndPostList())); diff --git a/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java b/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java index faa34f2a..53f42ac5 100644 --- a/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java +++ b/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java @@ -11,6 +11,7 @@ import com.mile.moim.service.dto.MoimInfoModifyRequest; import com.mile.moim.service.dto.MoimTopicResponse; import com.mile.moim.service.dto.TemporaryPostExistResponse; +import com.mile.moim.service.dto.TopicCreateRequest; import com.mile.moim.service.dto.TopicListResponse; import com.mile.moim.service.dto.PopularWriterListResponse; import com.mile.moim.service.dto.WriterNameConflictCheckResponse; @@ -239,4 +240,29 @@ ResponseEntity modifyMoimInformation( ResponseEntity> validateMoimName( @RequestParam final String moimName ); + + @Operation(summary = "관리자 페이지 글모임 글감 생성") + @ApiResponses( + value = { + @ApiResponse(responseCode = "201", description = "글감 생성이 완료되었습니다."), + @ApiResponse(responseCode = "400",description = "1. 글감은 최대 15자 이내로 작성해주세요.\n" + + "2. 글감 제목이 비어있습니다.\n" + "3. 글감 태그는 최대 5자 이내로 작성해주세요.\n" + + "4. 글감 태그가 비어있습니다.\n" + "5. 글감 설명은 최대 90자 이내로 작성해주세요." + ), + @ApiResponse(responseCode = "401", description = "로그인 후 이용해주세요.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "404", description = "해당 모임은 존재하지 않습니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "403", description = "사용자는 해당 모임의 모임장이 아닙니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + + @ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + } + ) + ResponseEntity createTopicOfMoim( + @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId, + @RequestBody final TopicCreateRequest createRequest, + @PathVariable("moimId") final String moimUrl + ); } diff --git a/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java b/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java index 0fecfa10..9844271e 100644 --- a/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java +++ b/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java @@ -38,6 +38,7 @@ public enum SuccessMessage { TOPIC_DETAIL_GET_SUCCESS(HttpStatus.OK.value(), "글감 상세 정보 조회가 완료되었습니다."), MOIM_INFORMATION_PUT_SUCCESS(HttpStatus.OK.value(), "모임 정보 수정이 완료되었습니다."), IS_CONFLICT_MOIM_NAME_GET_SUCCESS(HttpStatus.OK.value(), "글모임 이름 중복 확인이 완료되었습니다."), + TOPIC_CREATE_SUCCESS(HttpStatus.CREATED.value(), "글감 생성이 완료되었습니다."), /* 201 CREATED */ 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 71c4d8c5..4c30722a 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 @@ -16,6 +16,7 @@ import com.mile.moim.service.dto.MoimTopicResponse; import com.mile.moim.service.dto.PopularWriterListResponse; import com.mile.moim.service.dto.TemporaryPostExistResponse; +import com.mile.moim.service.dto.TopicCreateRequest; import com.mile.moim.service.dto.TopicListResponse; import com.mile.moim.service.dto.WriterMemberJoinRequest; import com.mile.moim.service.dto.WriterNameConflictCheckResponse; @@ -189,4 +190,15 @@ public MoimNameConflictCheckResponse validateMoimName( ) { return MoimNameConflictCheckResponse.of(!moimRepository.existsByName(moimName)); } + + + public String createTopic( + final Long moimId, + final Long userId, + final TopicCreateRequest createRequest + ) { + Moim moim = findById(moimId); + authenticateOwnerOfMoim(moim, userId); + return topicService.createTopicOfMoim(moim, createRequest).toString(); + } } diff --git a/module-domain/src/main/java/com/mile/moim/service/dto/TopicCreateRequest.java b/module-domain/src/main/java/com/mile/moim/service/dto/TopicCreateRequest.java new file mode 100644 index 00000000..e7973eeb --- /dev/null +++ b/module-domain/src/main/java/com/mile/moim/service/dto/TopicCreateRequest.java @@ -0,0 +1,18 @@ +package com.mile.moim.service.dto; + +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.NotBlank; + +public record TopicCreateRequest( + @Max(value = 15, message = "글감은 최대 15자 이내로 작성해주세요.") + @NotBlank(message = "글감 제목이 비어있습니다.") + String topicName, + @Max(value = 5, message = "글감 태그는 최대 5자 이내로 작성해주세요.") + @NotBlank(message = "글감 태그가 비어있습니다.") + String topicTag, + @Max(value = 90, message = "글감 설명은 최대 90자 이내로 작성해주세요.") + @NotBlank(message = "글감 설명은 비어있습니다.") + String topicDescription +) { + +} diff --git a/module-domain/src/main/java/com/mile/topic/domain/Topic.java b/module-domain/src/main/java/com/mile/topic/domain/Topic.java index 53525551..fe1655d7 100644 --- a/module-domain/src/main/java/com/mile/topic/domain/Topic.java +++ b/module-domain/src/main/java/com/mile/topic/domain/Topic.java @@ -2,24 +2,52 @@ import com.mile.config.BaseTimeEntity; import com.mile.moim.domain.Moim; +import com.mile.moim.service.dto.TopicCreateRequest; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.ManyToOne; +import lombok.Builder; import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; @Entity @Getter +@NoArgsConstructor public class Topic extends BaseTimeEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @ManyToOne(fetch = FetchType.LAZY) private Moim moim; + @Setter private String idUrl; private String keyword; private String content; private String description; + @Builder + private Topic(final Moim moim, + final String content, + final String keyword, + final String description) { + this.moim = moim; + this.content = content; + this.keyword = keyword; + this.description = description; + } + + public static Topic create( + final Moim moim, + final TopicCreateRequest topicCreateRequest + ) { + return Topic.builder() + .moim(moim) + .content(topicCreateRequest.topicName()) + .keyword(topicCreateRequest.topicTag()) + .description(topicCreateRequest.topicDescription()) + .build(); + } } 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 496ec4d1..2ddbeb16 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 @@ -6,6 +6,7 @@ import com.mile.exception.model.ForbiddenException; import com.mile.exception.model.NotFoundException; import com.mile.moim.domain.Moim; +import com.mile.moim.service.dto.TopicCreateRequest; import com.mile.post.service.PostGetService; import com.mile.post.service.dto.PostListResponse; import com.mile.topic.domain.Topic; @@ -18,6 +19,8 @@ import com.mile.topic.service.dto.TopicResponse; import com.mile.user.domain.User; import com.mile.user.service.UserService; +import com.mile.utils.SecureUrlUtil; +import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory; import org.springframework.stereotype.Service; @@ -34,6 +37,7 @@ public class TopicService { private final CommentService commentService; private final UserService userService; private final PostGetService postGetService; + private final SecureUrlUtil secureUrlUtil; public List getContentsFromMoim( final Long moimId @@ -144,4 +148,14 @@ public TopicDetailResponse getTopicDetail( authenticateTopicWithUser(topic, userService.findById(userId)); return TopicDetailResponse.of(topic); } + + @Transactional + public Long createTopicOfMoim( + final Moim moim, + final TopicCreateRequest createRequest + ) { + Topic topic = topicRepository.saveAndFlush(Topic.create(moim, createRequest)); + topic.setIdUrl(secureUrlUtil.encodeUrl(topic.getId())); + return topic.getId(); + } } From 2ec8006fbbc6ca0608912409879af272eb2ecd55 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Thu, 28 Mar 2024 09:27:42 +0900 Subject: [PATCH 11/21] =?UTF-8?q?#267=20[feat]=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/mile/moim/service/MoimService.java | 9 +++++++++ 1 file changed, 9 insertions(+) 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 4c30722a..5ec64800 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 @@ -10,6 +10,7 @@ import com.mile.moim.service.dto.MoimAuthenticateResponse; import com.mile.moim.service.dto.MoimCuriousPostListResponse; import com.mile.moim.service.dto.MoimInfoModifyRequest; +import com.mile.moim.service.dto.MoimInfoOwnerResponse; import com.mile.moim.service.dto.MoimInfoResponse; import com.mile.moim.service.dto.MoimNameConflictCheckResponse; import com.mile.moim.service.dto.MoimInvitationInfoResponse; @@ -201,4 +202,12 @@ public String createTopic( authenticateOwnerOfMoim(moim, userId); return topicService.createTopicOfMoim(moim, createRequest).toString(); } + public MoimInfoOwnerResponse getMoimInfoForOwner( + final Long moimId, + final Long userId + ) { + Moim moim = findById(moimId); + authenticateOwnerOfMoim(moim, userId); + return MoimInfoOwnerResponse.of(moim); + } } From 9b8ee7c0dc25421bd1438b0deeec797e63cb4bf6 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Thu, 28 Mar 2024 09:28:03 +0900 Subject: [PATCH 12/21] =?UTF-8?q?#267=20[feat]=20=EC=97=94=EB=93=9C?= =?UTF-8?q?=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mile/controller/moim/MoimController.java | 9 ++++++++ .../moim/MoimControllerSwagger.java | 21 +++++++++++++++++++ .../exception/message/SuccessMessage.java | 1 + .../service/dto/MoimInfoOwnerResponse.java | 17 +++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 module-domain/src/main/java/com/mile/moim/service/dto/MoimInfoOwnerResponse.java diff --git a/module-api/src/main/java/com/mile/controller/moim/MoimController.java b/module-api/src/main/java/com/mile/controller/moim/MoimController.java index bfe8e01e..8f1ed0eb 100644 --- a/module-api/src/main/java/com/mile/controller/moim/MoimController.java +++ b/module-api/src/main/java/com/mile/controller/moim/MoimController.java @@ -8,6 +8,7 @@ import com.mile.moim.service.dto.ContentListResponse; import com.mile.moim.service.dto.MoimAuthenticateResponse; import com.mile.moim.service.dto.MoimCuriousPostListResponse; +import com.mile.moim.service.dto.MoimInfoOwnerResponse; import com.mile.moim.service.dto.MoimInfoResponse; import com.mile.moim.service.dto.MoimNameConflictCheckResponse; import com.mile.moim.service.dto.MoimInvitationInfoResponse; @@ -137,6 +138,14 @@ public SuccessResponse getMostCuriousPostByMoim( return SuccessResponse.of(SuccessMessage.MOIM_TOP_2_POST_GET_SUCCESS, moimService.getMostCuriousPostFromMoim(moimId)); } + @Override + @GetMapping("/{moimId}/info/owner") + public ResponseEntity> getMoimInfoForOwner( + @MoimIdPathVariable final Long moimId, + @PathVariable("moimId") final String moimUrl + ) { + return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_INFO_FOR_OWNER_GET_SUCCESS, moimService.getMoimInfoForOwner(moimId, principalHandler.getUserIdFromPrincipal()))); + } @Override @PostMapping("/{moimId}/topic") public ResponseEntity createTopicOfMoim( diff --git a/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java b/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java index 53f42ac5..85b44e84 100644 --- a/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java +++ b/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java @@ -5,6 +5,7 @@ import com.mile.moim.service.dto.BestMoimListResponse; import com.mile.moim.service.dto.ContentListResponse; import com.mile.moim.service.dto.MoimCuriousPostListResponse; +import com.mile.moim.service.dto.MoimInfoOwnerResponse; import com.mile.moim.service.dto.MoimInfoResponse; import com.mile.moim.service.dto.MoimNameConflictCheckResponse; import com.mile.moim.service.dto.MoimInvitationInfoResponse; @@ -265,4 +266,24 @@ ResponseEntity createTopicOfMoim( @RequestBody final TopicCreateRequest createRequest, @PathVariable("moimId") final String moimUrl ); + @Operation(summary = "관리자 페이지 모임 정보 조회") + @ApiResponses( + value = { + @ApiResponse(responseCode = "200", description = "관리자 페이지의 모임 정보가 조회되었습니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "401", description = "로그인 후 이용해주세요.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "403", description = "사용자는 해당 모임의 모임장이 아닙니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "404", description = "해당 모임은 존재하지 않습니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + } + ) + ResponseEntity> getMoimInfoForOwner( + @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId, + @PathVariable("moimId") final String moimUrl + ); + } diff --git a/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java b/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java index 9844271e..eb036249 100644 --- a/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java +++ b/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java @@ -39,6 +39,7 @@ public enum SuccessMessage { MOIM_INFORMATION_PUT_SUCCESS(HttpStatus.OK.value(), "모임 정보 수정이 완료되었습니다."), IS_CONFLICT_MOIM_NAME_GET_SUCCESS(HttpStatus.OK.value(), "글모임 이름 중복 확인이 완료되었습니다."), TOPIC_CREATE_SUCCESS(HttpStatus.CREATED.value(), "글감 생성이 완료되었습니다."), + MOIM_INFO_FOR_OWNER_GET_SUCCESS(HttpStatus.OK.value(), "관리자 페이지의 모임 정보가 조회되었습니다."), /* 201 CREATED */ diff --git a/module-domain/src/main/java/com/mile/moim/service/dto/MoimInfoOwnerResponse.java b/module-domain/src/main/java/com/mile/moim/service/dto/MoimInfoOwnerResponse.java new file mode 100644 index 00000000..9b342daa --- /dev/null +++ b/module-domain/src/main/java/com/mile/moim/service/dto/MoimInfoOwnerResponse.java @@ -0,0 +1,17 @@ +package com.mile.moim.service.dto; + +import com.mile.moim.domain.Moim; + +public record MoimInfoOwnerResponse( + String moimTitle, + String description, + String imageUrl, + boolean isPublic +) { + + public static MoimInfoOwnerResponse of( + final Moim moim + ) { + return new MoimInfoOwnerResponse(moim.getName(), moim.getInformation(), moim.getImageUrl(), moim.isPublic()); + } +} \ No newline at end of file From 76dbbe891f24411b3630c25ec8e09e184acb5013 Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Thu, 28 Mar 2024 09:44:49 +0900 Subject: [PATCH 13/21] =?UTF-8?q?#271=20[refactor]=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/writername/WriterNameControllerSwagger.java | 2 +- .../com/mile/writername/service/WriterNameDeleteService.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/module-api/src/main/java/com/mile/controller/writername/WriterNameControllerSwagger.java b/module-api/src/main/java/com/mile/controller/writername/WriterNameControllerSwagger.java index 6dc146cc..23ecab4e 100644 --- a/module-api/src/main/java/com/mile/controller/writername/WriterNameControllerSwagger.java +++ b/module-api/src/main/java/com/mile/controller/writername/WriterNameControllerSwagger.java @@ -18,7 +18,7 @@ public interface WriterNameControllerSwagger { @ApiResponses( value = { @ApiResponse(responseCode = "200", description = "멤버 삭제가 완료되었습니다."), - @ApiResponse(responseCode = "404", description = "해당 모임은 존재하지 않습니다."), + @ApiResponse(responseCode = "404", description = "해당 사용자는 존재하지 않습니다."), @ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) } diff --git a/module-domain/src/main/java/com/mile/writername/service/WriterNameDeleteService.java b/module-domain/src/main/java/com/mile/writername/service/WriterNameDeleteService.java index d6f69611..71a1135c 100644 --- a/module-domain/src/main/java/com/mile/writername/service/WriterNameDeleteService.java +++ b/module-domain/src/main/java/com/mile/writername/service/WriterNameDeleteService.java @@ -29,9 +29,8 @@ public void deleteWriterNameById( private WriterName findById( final Long writerNameId ) { - WriterName writerName = writerNameRepository.findById(writerNameId).orElseThrow( + return writerNameRepository.findById(writerNameId).orElseThrow( () -> new NotFoundException(ErrorMessage.WRITER_NOT_FOUND) ); - return writerName; } } From 10d5468ef8f547eee3544810348a3e719bc5a2a2 Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Fri, 29 Mar 2024 00:31:23 +0900 Subject: [PATCH 14/21] =?UTF-8?q?#260=20[refactor]=20=EC=97=94=EB=93=9C?= =?UTF-8?q?=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20?= =?UTF-8?q?=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mile/controller/moim/MoimController.java | 9 -------- .../moim/MoimControllerSwagger.java | 15 ------------- .../controller/topic/TopicController.java | 14 ++++++++++++ .../topic/TopicControllerSwagger.java | 22 +++++++++++++++++++ 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/module-api/src/main/java/com/mile/controller/moim/MoimController.java b/module-api/src/main/java/com/mile/controller/moim/MoimController.java index 94b5362e..69611aae 100644 --- a/module-api/src/main/java/com/mile/controller/moim/MoimController.java +++ b/module-api/src/main/java/com/mile/controller/moim/MoimController.java @@ -174,15 +174,6 @@ public SuccessResponse getTemporaryPost( } - @Override - @PutMapping("/{moimId}/topic/{topicId}") - public ResponseEntity putTopic( - @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId, - @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long topicId - ) { - return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.TOPIC_PUT_SUCCESS)); - } - @Override @PutMapping("/{moimId}/info") public ResponseEntity modifyMoimInformation( diff --git a/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java b/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java index a89c4094..206cddd6 100644 --- a/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java +++ b/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java @@ -213,21 +213,6 @@ ResponseEntity joinMoim( @PathVariable("moimId") final String moimUrl ); - @Operation(summary = "글모임 글감 수정") - @ApiResponses( - value = { - @ApiResponse(responseCode = "200", description = "글감 수정이 완료되었습니다."), - @ApiResponse(responseCode = "400", description = "입력 값이 유효하지 않습니다."), - @ApiResponse(responseCode = "403", description = "사용자는 해당 모임의 모임장이 아닙니다."), - @ApiResponse(responseCode = "404", description = "해당 모임은 존재하지 않습니다."), - @ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.", - content = @Content(schema = @Schema(implementation = ErrorResponse.class))) - } - ) - ResponseEntity putTopic( - @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId, - @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long topicId - ); @Operation(summary = "관리자 페이지 모임 정보 수정") diff --git a/module-api/src/main/java/com/mile/controller/topic/TopicController.java b/module-api/src/main/java/com/mile/controller/topic/TopicController.java index 42ff323f..f8373b81 100644 --- a/module-api/src/main/java/com/mile/controller/topic/TopicController.java +++ b/module-api/src/main/java/com/mile/controller/topic/TopicController.java @@ -7,6 +7,7 @@ import com.mile.topic.service.TopicService; import com.mile.topic.service.dto.PostListInTopicResponse; import com.mile.topic.service.dto.TopicDetailResponse; +import com.mile.topic.service.dto.TopicPutRequest; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.media.Schema; @@ -14,6 +15,8 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -42,4 +45,15 @@ public ResponseEntity> getTopicDetail( ) { return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.TOPIC_DETAIL_GET_SUCCESS ,topicService.getTopicDetail(principalHandler.getUserIdFromPrincipal(), topicId))); } + + @Override + @PutMapping("/{topicId}") + public ResponseEntity putTopic( + @RequestBody final TopicPutRequest topicPutRequest, + @TopicIdPathVariable final Long topicId, + @PathVariable("topicId") final String topicUrl + ) { + topicService.putTopic(principalHandler.getUserIdFromPrincipal(), topicId, topicPutRequest); + return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.TOPIC_PUT_SUCCESS)); + } } diff --git a/module-api/src/main/java/com/mile/controller/topic/TopicControllerSwagger.java b/module-api/src/main/java/com/mile/controller/topic/TopicControllerSwagger.java index 55cf7dd1..e551dfd6 100644 --- a/module-api/src/main/java/com/mile/controller/topic/TopicControllerSwagger.java +++ b/module-api/src/main/java/com/mile/controller/topic/TopicControllerSwagger.java @@ -5,6 +5,7 @@ import com.mile.dto.SuccessResponse; import com.mile.topic.service.dto.PostListInTopicResponse; import com.mile.topic.service.dto.TopicDetailResponse; +import com.mile.topic.service.dto.TopicPutRequest; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.ParameterIn; @@ -15,6 +16,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; @Tag(name = "Topic") public interface TopicControllerSwagger { @@ -54,4 +56,24 @@ ResponseEntity> getTopicDetail( @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long topicId, @PathVariable("topicId") final String topicUrl ); + + @Operation(summary = "글감 수정") + @ApiResponses( + value = { + @ApiResponse(responseCode = "200", description = "글감 수정이 완료되었습니다."), + @ApiResponse(responseCode = "400" ,description = "1. 글감은 최대 15자 이내로 작성해주세요.\n" + + "2. 글감 태그는 최대 5자 이내로 작성해주세요.\n" + + "3. 글감 소개글은 최대 90자 이내로 작성해주세요."), + @ApiResponse(responseCode = "400", description = "입력 값이 유효하지 않습니다."), + @ApiResponse(responseCode = "403", description = "사용자는 해당 모임의 모임장이 아닙니다."), + @ApiResponse(responseCode = "404", description = "해당 글감은 존재하지 않습니다."), + @ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + } + ) + ResponseEntity putTopic( + @RequestBody final TopicPutRequest topicPutRequest, + @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long topicId, + @PathVariable("topicId") final String topicUrl + ); } From d7b5521f352dce0ef6e93444bdecd4b86b00e120 Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Fri, 29 Mar 2024 00:31:46 +0900 Subject: [PATCH 15/21] =?UTF-8?q?#260=20[feat]=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20update=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/mile/topic/domain/Topic.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/module-domain/src/main/java/com/mile/topic/domain/Topic.java b/module-domain/src/main/java/com/mile/topic/domain/Topic.java index fe1655d7..0020d7eb 100644 --- a/module-domain/src/main/java/com/mile/topic/domain/Topic.java +++ b/module-domain/src/main/java/com/mile/topic/domain/Topic.java @@ -3,6 +3,7 @@ import com.mile.config.BaseTimeEntity; import com.mile.moim.domain.Moim; import com.mile.moim.service.dto.TopicCreateRequest; +import com.mile.topic.service.dto.TopicPutRequest; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; @@ -50,4 +51,13 @@ public static Topic create( .description(topicCreateRequest.topicDescription()) .build(); } + + public void updateTopic( + final TopicPutRequest putRequest + ) { + this.content = putRequest.topic(); + this.keyword = putRequest.topicTag(); + this.description = putRequest.topicDescription(); + } + } From df068fa751843b124428db93afcdeab16d806e2e Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Fri, 29 Mar 2024 00:32:08 +0900 Subject: [PATCH 16/21] =?UTF-8?q?#260=20[feat]=20=EA=B8=80=EA=B0=90=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EC=84=9C=EB=B9=84=EC=8A=A4=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mile/topic/service/TopicService.java | 14 ++++++++++++++ .../topic/service/dto/TopicPutRequest.java | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 module-domain/src/main/java/com/mile/topic/service/dto/TopicPutRequest.java 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 2ddbeb16..98fa2c99 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 @@ -16,6 +16,7 @@ import com.mile.topic.service.dto.PostListInTopicResponse; import com.mile.topic.service.dto.TopicDetailResponse; import com.mile.topic.service.dto.TopicOfMoimResponse; +import com.mile.topic.service.dto.TopicPutRequest; import com.mile.topic.service.dto.TopicResponse; import com.mile.user.domain.User; import com.mile.user.service.UserService; @@ -158,4 +159,17 @@ public Long createTopicOfMoim( topic.setIdUrl(secureUrlUtil.encodeUrl(topic.getId())); return topic.getId(); } + + @Transactional + public void putTopic( + final Long userId, + final Long topicId, + final TopicPutRequest topicPutRequest + ) { + Topic topic = findById(topicId); + User user = userService.findById(userId); + authenticateTopicWithUser(topic, user); + topic.updateTopic(topicPutRequest); + } + } diff --git a/module-domain/src/main/java/com/mile/topic/service/dto/TopicPutRequest.java b/module-domain/src/main/java/com/mile/topic/service/dto/TopicPutRequest.java new file mode 100644 index 00000000..3701546c --- /dev/null +++ b/module-domain/src/main/java/com/mile/topic/service/dto/TopicPutRequest.java @@ -0,0 +1,18 @@ +package com.mile.topic.service.dto; + + +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.NotBlank; + +public record TopicPutRequest( + @Max(value = 15, message = "글감은 최대 15자 이내로 작성해주세요.") + @NotBlank(message = "글감 제목이 비어 있습니다.") + String topic, + @Max(value = 5, message = "글감 태그는 최대 5자 이내로 작성해주세요.") + @NotBlank(message = "글감 태그가 비어 있습니다.") + String topicTag, + @Max(value = 90, message = "글감 소개글은 최대 90자 이내로 작성해주세요.") + @NotBlank(message = "글감 설명은 비어 있습니다.") + String topicDescription +) { +} From c81b70b461d0ba07b8230c0212108dc78707ffbb Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Fri, 29 Mar 2024 11:18:00 +0900 Subject: [PATCH 17/21] =?UTF-8?q?#272=20[feat]=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mile/controller/moim/MoimController.java | 11 ++++++++++ .../moim/MoimControllerSwagger.java | 21 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/module-api/src/main/java/com/mile/controller/moim/MoimController.java b/module-api/src/main/java/com/mile/controller/moim/MoimController.java index 8f1ed0eb..956623eb 100644 --- a/module-api/src/main/java/com/mile/controller/moim/MoimController.java +++ b/module-api/src/main/java/com/mile/controller/moim/MoimController.java @@ -14,6 +14,7 @@ import com.mile.moim.service.dto.MoimInvitationInfoResponse; import com.mile.moim.service.dto.MoimInfoModifyRequest; import com.mile.moim.service.dto.MoimTopicResponse; +import com.mile.moim.service.dto.MoimWriterNameListGetResponse; import com.mile.moim.service.dto.PopularWriterListResponse; import com.mile.moim.service.dto.TemporaryPostExistResponse; import com.mile.moim.service.dto.TopicCreateRequest; @@ -186,4 +187,14 @@ public ResponseEntity> validateMo ) { return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.IS_CONFLICT_MOIM_NAME_GET_SUCCESS, moimService.validateMoimName(moimName))); } + + @Override + @GetMapping("/{moimId}/writerNameList") + public ResponseEntity> getWriterNameListOfMoim( + @MoimIdPathVariable final Long moimId, + @RequestParam final int page, + @PathVariable("moimId") final String moimUrl + ) { + return ResponseEntity.ok(SuccessResponse.of(SuccessMessage.MOIM_WRITERNAME_LIST_GET_SUCCESS, moimService.getWriterNameListOfMoim(moimId, principalHandler.getUserIdFromPrincipal(), page))); + }; } diff --git a/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java b/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java index 85b44e84..004d5c57 100644 --- a/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java +++ b/module-api/src/main/java/com/mile/controller/moim/MoimControllerSwagger.java @@ -11,6 +11,7 @@ import com.mile.moim.service.dto.MoimInvitationInfoResponse; import com.mile.moim.service.dto.MoimInfoModifyRequest; import com.mile.moim.service.dto.MoimTopicResponse; +import com.mile.moim.service.dto.MoimWriterNameListGetResponse; import com.mile.moim.service.dto.TemporaryPostExistResponse; import com.mile.moim.service.dto.TopicCreateRequest; import com.mile.moim.service.dto.TopicListResponse; @@ -286,4 +287,24 @@ ResponseEntity> getMoimInfoForOwner( @PathVariable("moimId") final String moimUrl ); + @Operation(summary = "관리자 페이지 멤버 리스트 조회") + @ApiResponses( + value = { + @ApiResponse(responseCode = "200", description = "멤버 리스트 조회가 조회되었습니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "401", description = "로그인 후 이용해주세요.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "403", description = "사용자는 해당 모임의 모임장이 아닙니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "404", description = "해당 모임은 존재하지 않습니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류입니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + } + ) + ResponseEntity> getWriterNameListOfMoim( + @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) final Long moimId, + @RequestParam final int page, + @PathVariable("moimId") final String moimUrl + ); } From 35554fb809a7d69c4bcc9b3559cfc7cecf6d8f96 Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Fri, 29 Mar 2024 11:18:34 +0900 Subject: [PATCH 18/21] =?UTF-8?q?#272=20[feat]=20=EC=9D=91=EB=8B=B5=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/MoimWriterNameListGetResponse.java | 18 ++++++++++++++++++ .../service/dto/WriterNameInfoResponse.java | 15 +++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 module-domain/src/main/java/com/mile/moim/service/dto/MoimWriterNameListGetResponse.java create mode 100644 module-domain/src/main/java/com/mile/writername/service/dto/WriterNameInfoResponse.java diff --git a/module-domain/src/main/java/com/mile/moim/service/dto/MoimWriterNameListGetResponse.java b/module-domain/src/main/java/com/mile/moim/service/dto/MoimWriterNameListGetResponse.java new file mode 100644 index 00000000..33eab5f1 --- /dev/null +++ b/module-domain/src/main/java/com/mile/moim/service/dto/MoimWriterNameListGetResponse.java @@ -0,0 +1,18 @@ +package com.mile.moim.service.dto; + +import com.mile.writername.service.dto.WriterNameInfoResponse; +import java.util.List; + +public record MoimWriterNameListGetResponse( + int pageNumber, + int writerNameCount, + List writerNameList +) { + public static MoimWriterNameListGetResponse of( + final int pageNumber, + final int writerNameCount, + final List writerNameList + ) { + return new MoimWriterNameListGetResponse(pageNumber, writerNameCount, writerNameList); + } +} diff --git a/module-domain/src/main/java/com/mile/writername/service/dto/WriterNameInfoResponse.java b/module-domain/src/main/java/com/mile/writername/service/dto/WriterNameInfoResponse.java new file mode 100644 index 00000000..18836395 --- /dev/null +++ b/module-domain/src/main/java/com/mile/writername/service/dto/WriterNameInfoResponse.java @@ -0,0 +1,15 @@ +package com.mile.writername.service.dto; + +public record WriterNameInfoResponse( + Long writerNameId, + String writerName, + String information +) { + public static WriterNameInfoResponse of( + final Long writerNameId, + final String writerName, + final String information + ) { + return new WriterNameInfoResponse(writerNameId, writerName, information); + } +} From e7b48de55c48f9e2bcf992c9176cacaa74dd163d Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Fri, 29 Mar 2024 11:20:04 +0900 Subject: [PATCH 19/21] =?UTF-8?q?#272=20[feat]=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=EB=84=A4=EC=9D=B4=EC=85=98=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=A9=A4=EB=B2=84=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=84=9C=EB=B9=84=EC=8A=A4=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/message/SuccessMessage.java | 1 + .../com/mile/moim/service/MoimService.java | 12 +++++++ .../repository/WriterNameRepository.java | 4 ++- .../writername/service/WriterNameService.java | 31 +++++++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java b/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java index eb036249..44f5ba66 100644 --- a/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java +++ b/module-common/src/main/java/com/mile/exception/message/SuccessMessage.java @@ -40,6 +40,7 @@ public enum SuccessMessage { IS_CONFLICT_MOIM_NAME_GET_SUCCESS(HttpStatus.OK.value(), "글모임 이름 중복 확인이 완료되었습니다."), TOPIC_CREATE_SUCCESS(HttpStatus.CREATED.value(), "글감 생성이 완료되었습니다."), MOIM_INFO_FOR_OWNER_GET_SUCCESS(HttpStatus.OK.value(), "관리자 페이지의 모임 정보가 조회되었습니다."), + MOIM_WRITERNAME_LIST_GET_SUCCESS(HttpStatus.OK.value(), "멤버 리스트 조회가 완료되었습니다."), /* 201 CREATED */ 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 5ec64800..3d4360e4 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 @@ -15,6 +15,7 @@ import com.mile.moim.service.dto.MoimNameConflictCheckResponse; import com.mile.moim.service.dto.MoimInvitationInfoResponse; import com.mile.moim.service.dto.MoimTopicResponse; +import com.mile.moim.service.dto.MoimWriterNameListGetResponse; import com.mile.moim.service.dto.PopularWriterListResponse; import com.mile.moim.service.dto.TemporaryPostExistResponse; import com.mile.moim.service.dto.TopicCreateRequest; @@ -33,6 +34,7 @@ import com.mile.utils.SecureUrlUtil; import com.mile.writername.domain.WriterName; import com.mile.writername.service.WriterNameService; +import com.mile.writername.service.dto.WriterNameInfoResponse; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -210,4 +212,14 @@ public MoimInfoOwnerResponse getMoimInfoForOwner( authenticateOwnerOfMoim(moim, userId); return MoimInfoOwnerResponse.of(moim); } + + public MoimWriterNameListGetResponse getWriterNameListOfMoim( + final Long moimId, + final Long userId, + final int page + ) { + Moim moim = findById(moimId); + authenticateOwnerOfMoim(moim, userId); + return writerNameService.getWriterNameInfoList(moimId, page); + } } diff --git a/module-domain/src/main/java/com/mile/writername/repository/WriterNameRepository.java b/module-domain/src/main/java/com/mile/writername/repository/WriterNameRepository.java index 7fc6c472..f94aff76 100644 --- a/module-domain/src/main/java/com/mile/writername/repository/WriterNameRepository.java +++ b/module-domain/src/main/java/com/mile/writername/repository/WriterNameRepository.java @@ -2,6 +2,8 @@ import com.mile.moim.domain.Moim; import com.mile.writername.domain.WriterName; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; @@ -20,5 +22,5 @@ public interface WriterNameRepository extends JpaRepository { Optional findByWriterId(final Long userId); List findTop2ByMoimIdAndTotalCuriousCountGreaterThanOrderByTotalCuriousCountDesc(final Long moimId, final int totalCuriousCount); - + Page findByMoimIdOrderByIdDesc(Long moimId, Pageable pageable); } \ No newline at end of file diff --git a/module-domain/src/main/java/com/mile/writername/service/WriterNameService.java b/module-domain/src/main/java/com/mile/writername/service/WriterNameService.java index 14571c58..e1224936 100644 --- a/module-domain/src/main/java/com/mile/writername/service/WriterNameService.java +++ b/module-domain/src/main/java/com/mile/writername/service/WriterNameService.java @@ -3,12 +3,18 @@ import com.mile.exception.message.ErrorMessage; import com.mile.exception.model.NotFoundException; import com.mile.moim.domain.Moim; +import com.mile.moim.service.dto.MoimWriterNameListGetResponse; import com.mile.moim.service.dto.WriterMemberJoinRequest; import com.mile.post.domain.Post; import com.mile.user.domain.User; import com.mile.writername.domain.WriterName; import com.mile.writername.repository.WriterNameRepository; +import com.mile.writername.service.dto.WriterNameInfoResponse; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -20,6 +26,7 @@ public class WriterNameService { private final WriterNameRepository writerNameRepository; private static final int MIN_TOTAL_CURIOUS_COUNT = 0; + private static final int WRITERNAME_PER_PAGE_SIZE = 5; public boolean isUserInMoim( final Long moimId, @@ -107,4 +114,28 @@ public Long createWriterName(final User user, final Moim moim, final WriterMembe writerNameRepository.saveAndFlush(writerName); return writerName.getId(); } + + private List findAllByMoimId( + final Long moimId + ) { + return writerNameRepository.findByMoimId(moimId); + } + + public MoimWriterNameListGetResponse getWriterNameInfoList( + final Long moimId, + final int page + ) { + PageRequest pageRequest = PageRequest.of(page-1, WRITERNAME_PER_PAGE_SIZE, Sort.by(Sort.Direction.DESC, "id")); + Page writerNamePage = writerNameRepository.findByMoimIdOrderByIdDesc(moimId, pageRequest); + List infoResponses = writerNamePage.getContent() + .stream() + .map(writerName -> WriterNameInfoResponse.of(writerName.getId(), writerName.getName(), writerName.getInformation())) + .collect(Collectors.toList()); + + return MoimWriterNameListGetResponse.of( + writerNamePage.getTotalPages(), + findNumbersOfWritersByMoimId(moimId), + infoResponses + ); + } } From 705a86cc7ecc6ff6bcca61c51490d3ad24217ee6 Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Fri, 29 Mar 2024 11:49:22 +0900 Subject: [PATCH 20/21] =?UTF-8?q?#257=20[refactor]=20=EC=B4=9D=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EA=B0=9C=EC=88=98=EB=8F=84=20=EB=A6=AC?= =?UTF-8?q?=ED=84=B4=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/mile/moim/service/MoimService.java | 2 +- .../moim/service/dto/MoimTopicInfoListResponse.java | 3 +++ .../java/com/mile/topic/service/TopicService.java | 12 +++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) 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 04127c9d..be1f9214 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 @@ -185,7 +185,7 @@ public MoimTopicInfoListResponse getMoimTopicList( final int page ) { getAuthenticateOwnerOfMoim(moimId, userId); - return MoimTopicInfoListResponse.of(topicService.getNumberOfTopicFromMoim(moimId), topicService.getTopicListFromMoim(moimId, page)); + return topicService.getTopicListFromMoim(moimId, page); } private void getAuthenticateOwnerOfMoim( diff --git a/module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoListResponse.java b/module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoListResponse.java index 602db898..1003ab33 100644 --- a/module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoListResponse.java +++ b/module-domain/src/main/java/com/mile/moim/service/dto/MoimTopicInfoListResponse.java @@ -3,14 +3,17 @@ import java.util.List; public record MoimTopicInfoListResponse( + int pageNumber, Long topicCount, List topics ) { public static MoimTopicInfoListResponse of ( + final int pageNumber, final Long topicCount, final List moimTopicInfoResponses ) { return new MoimTopicInfoListResponse( + pageNumber, topicCount, moimTopicInfoResponses ); 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 0f021ca5..bb1bb6f6 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 @@ -6,6 +6,7 @@ import com.mile.exception.model.ForbiddenException; import com.mile.exception.model.NotFoundException; import com.mile.moim.domain.Moim; +import com.mile.moim.service.dto.MoimTopicInfoListResponse; import com.mile.moim.service.dto.MoimTopicInfoResponse; import com.mile.moim.service.dto.TopicCreateRequest; import com.mile.post.service.PostGetService; @@ -146,7 +147,7 @@ public PostListInTopicResponse getPostListByTopic( postGetService.findByTopic(topic).stream().map(p -> PostListResponse.of(p, commentService.findCommentCountByPost(p))).collect(Collectors.toList())); } - public List getTopicListFromMoim( + public MoimTopicInfoListResponse getTopicListFromMoim( final Long moimId, final int page ) { @@ -155,11 +156,16 @@ public List getTopicListFromMoim( Page topicPage = topicRepository.findByMoimIdOrderByCreatedAtDesc(moimId, pageRequest); isContentsEmpty(topicPage.getContent()); - - return topicPage.getContent() + List infoResponses = topicPage.getContent() .stream() .map(MoimTopicInfoResponse::of) .collect(Collectors.toList()); + + return MoimTopicInfoListResponse.of( + topicPage.getTotalPages(), + getNumberOfTopicFromMoim(moimId), + infoResponses + ); } public Long getNumberOfTopicFromMoim( From 6c2019a7ada65986ea8f76c585bd2455acda0fda Mon Sep 17 00:00:00 2001 From: parkheeddong Date: Tue, 2 Apr 2024 23:10:12 +0900 Subject: [PATCH 21/21] =?UTF-8?q?#257=20[refactor]=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/mile/topic/service/TopicService.java | 5 +++++ 1 file changed, 5 insertions(+) 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 bb1bb6f6..a9db7a1e 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 @@ -156,6 +156,11 @@ public MoimTopicInfoListResponse getTopicListFromMoim( Page topicPage = topicRepository.findByMoimIdOrderByCreatedAtDesc(moimId, pageRequest); isContentsEmpty(topicPage.getContent()); + + return getTopicResponsesFromPage(topicPage, moimId); + } + + public MoimTopicInfoListResponse getTopicResponsesFromPage(Page topicPage, final Long moimId) { List infoResponses = topicPage.getContent() .stream() .map(MoimTopicInfoResponse::of)