From 0c236538dc7e99ce690b457b70547ff6a5afc316 Mon Sep 17 00:00:00 2001 From: mingmingmon Date: Tue, 6 Aug 2024 13:17:22 +0900 Subject: [PATCH 1/7] =?UTF-8?q?refactor(responseDto):=20ActivityGoupBoard?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8A=94=20res?= =?UTF-8?q?ponseDto=EC=97=90=20=EC=9E=91=EC=84=B1=EC=9E=90=20id=EC=99=80?= =?UTF-8?q?=20=EC=9D=B4=EB=A6=84=20=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=B6=94=EA=B0=80=20#447?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ActivityGroupBoardService.java | 25 +++++++++++++------ .../ActivityGroupMemberService.java | 10 ++++++-- .../ActivityGroupBoardChildResponseDto.java | 9 +++++-- .../ActivityGroupBoardResponseDto.java | 13 +++++++++- .../ActivityGroupProjectResponseDto.java | 4 +-- .../ActivityGroupStudyResponseDto.java | 4 +-- ...mentSubmissionWithFeedbackResponseDto.java | 6 ++++- .../dto/response/FeedbackResponseDto.java | 13 +++++++++- 8 files changed, 65 insertions(+), 19 deletions(-) diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java index 53b15de45..2a54a5dcb 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java @@ -20,6 +20,7 @@ import page.clab.api.domain.activity.activitygroup.dto.response.AssignmentSubmissionWithFeedbackResponseDto; import page.clab.api.domain.activity.activitygroup.dto.response.FeedbackResponseDto; import page.clab.api.domain.activity.activitygroup.exception.InvalidParentBoardException; +import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; import page.clab.api.domain.memberManagement.member.domain.Member; import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.external.memberManagement.notification.application.port.ExternalSendNotificationUseCase; @@ -69,19 +70,19 @@ public Long createActivityGroupBoard(Long parentId, Long activityGroupId, Activi @Transactional(readOnly = true) public PagedResponseDto getAllActivityGroupBoard(Pageable pageable) { Page boards = activityGroupBoardRepository.findAll(pageable); - return new PagedResponseDto<>(boards.map(ActivityGroupBoardResponseDto::toDto)); + return new PagedResponseDto<>(boards.map(board -> ActivityGroupBoardResponseDto.toActivityGroupBoardResponseDtoWithMemberInfo(board, externalRetrieveMemberUseCase))); } @Transactional(readOnly = true) public ActivityGroupBoardResponseDto getActivityGroupBoardById(Long activityGroupBoardId) { ActivityGroupBoard board = getActivityGroupBoardByIdOrThrow(activityGroupBoardId); - return ActivityGroupBoardResponseDto.toDto(board); + return ActivityGroupBoardResponseDto.toActivityGroupBoardResponseDtoWithMemberInfo(board, externalRetrieveMemberUseCase); } @Transactional(readOnly = true) public PagedResponseDto getActivityGroupBoardByCategory(Long activityGroupId, ActivityGroupBoardCategory category, Pageable pageable) { Page boards = activityGroupBoardRepository.findAllByActivityGroup_IdAndCategory(activityGroupId, category, pageable); - return new PagedResponseDto<>(boards.map(ActivityGroupBoardResponseDto::toDto)); + return new PagedResponseDto<>(boards.map(board -> ActivityGroupBoardResponseDto.toActivityGroupBoardResponseDtoWithMemberInfo(board, externalRetrieveMemberUseCase))); } @Transactional(readOnly = true) @@ -95,7 +96,7 @@ public PagedResponseDto getActivityGroupBoar List childBoards = getChildBoards(parentId); Page boards = new PageImpl<>(childBoards, pageable, childBoards.size()); - return new PagedResponseDto<>(boards.map(ActivityGroupBoardChildResponseDto::toDto)); + return new PagedResponseDto<>(boards.map(this::toActivityGroupBoardChildResponseDtoWithMemberInfo)); } @Transactional(readOnly = true) @@ -107,9 +108,9 @@ public List getMyAssignmentsWithFee .map(submission -> { List feedbackDtos = submission.getChildren().stream() .filter(ActivityGroupBoard::isFeedback) - .map(FeedbackResponseDto::toDto) + .map(board -> FeedbackResponseDto.toFeedbackResponseDtoWithMemberInfo(board, externalRetrieveMemberUseCase)) .toList(); - return AssignmentSubmissionWithFeedbackResponseDto.toDto(submission, feedbackDtos); + return AssignmentSubmissionWithFeedbackResponseDto.toDto(submission, currentMember.getId(), currentMember.getName(), feedbackDtos); }) .toList(); } @@ -135,8 +136,8 @@ public Long deleteActivityGroupBoard(Long activityGroupBoardId) throws Permissio @Transactional(readOnly = true) public PagedResponseDto getDeletedActivityGroupBoards(Pageable pageable) { - Page activityGroupBoards = activityGroupBoardRepository.findAllByIsDeletedTrue(pageable); - return new PagedResponseDto<>(activityGroupBoards.map(ActivityGroupBoardResponseDto::toDto)); + Page boards = activityGroupBoardRepository.findAllByIsDeletedTrue(pageable); + return new PagedResponseDto<>(boards.map(board -> ActivityGroupBoardResponseDto.toActivityGroupBoardResponseDtoWithMemberInfo(board, externalRetrieveMemberUseCase))); } private ActivityGroupBoard getActivityGroupBoardByIdOrThrow(Long activityGroupBoardId) { @@ -151,6 +152,14 @@ private List getChildBoards(Long activityGroupBoardId) { return children; } + public ActivityGroupBoardChildResponseDto toActivityGroupBoardChildResponseDtoWithMemberInfo(ActivityGroupBoard activityGroupBoard) { + MemberDetailedInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberDetailedInfoById(activityGroupBoard.getMemberId()); + List childrenDtos = activityGroupBoard.getChildren().stream() + .map(child -> toActivityGroupBoardChildResponseDtoWithMemberInfo(child)) + .toList(); + return ActivityGroupBoardChildResponseDto.toDto(activityGroupBoard, memberInfo, childrenDtos); + } + private void validateParentBoard(ActivityGroupBoardCategory category, Long parentId) throws InvalidParentBoardException { if ((category == ActivityGroupBoardCategory.NOTICE || category == ActivityGroupBoardCategory.WEEKLY_ACTIVITY)) { if (parentId != null) { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupMemberService.java b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupMemberService.java index 9dae79cee..235ab314d 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupMemberService.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupMemberService.java @@ -23,6 +23,7 @@ import page.clab.api.domain.activity.activitygroup.dto.param.ActivityGroupDetails; import page.clab.api.domain.activity.activitygroup.dto.param.GroupScheduleDto; import page.clab.api.domain.activity.activitygroup.dto.request.ApplyFormRequestDto; +import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupBoardResponseDto; import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupProjectResponseDto; import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupResponseDto; import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupStatusResponseDto; @@ -69,10 +70,15 @@ public Object getActivityGroup(Long activityGroupId) { .map(groupMember -> GroupMemberResponseDto.toDto(externalRetrieveMemberUseCase.findByIdOrThrow(groupMember.getMemberId()), groupMember)) .toList(); + List activityGroupResponseDtos = + details.getActivityGroupBoards().stream() + .map(board -> ActivityGroupBoardResponseDto.toActivityGroupBoardResponseDtoWithMemberInfo(board, externalRetrieveMemberUseCase)) + .toList(); + if (details.getActivityGroup().isStudy()) { - return ActivityGroupStudyResponseDto.create(details.getActivityGroup(), details.getGroupMembers(), details.getActivityGroupBoards(), groupMemberResponseDtos, isOwner); + return ActivityGroupStudyResponseDto.create(details.getActivityGroup(), details.getGroupMembers(), activityGroupResponseDtos, groupMemberResponseDtos, isOwner); } else if (details.getActivityGroup().isProject()) { - return ActivityGroupProjectResponseDto.create(details.getActivityGroup(), details.getGroupMembers(), details.getActivityGroupBoards(), groupMemberResponseDtos, isOwner); + return ActivityGroupProjectResponseDto.create(details.getActivityGroup(), details.getGroupMembers(), activityGroupResponseDtos, groupMemberResponseDtos, isOwner); } else { throw new InvalidCategoryException("해당 카테고리가 존재하지 않습니다."); } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardChildResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardChildResponseDto.java index c5ff5d329..c0ed5fb9d 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardChildResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardChildResponseDto.java @@ -4,6 +4,7 @@ import lombok.Getter; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoard; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoardCategory; +import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; import java.time.LocalDateTime; @@ -14,6 +15,8 @@ public class ActivityGroupBoardChildResponseDto { private Long id; + private String memberId; + private String memberName; private ActivityGroupBoardCategory category; private String title; private String content; @@ -23,9 +26,11 @@ public class ActivityGroupBoardChildResponseDto { private List files; private List children; - public static ActivityGroupBoardChildResponseDto toDto(ActivityGroupBoard board) { + public static ActivityGroupBoardChildResponseDto toDto(ActivityGroupBoard board, MemberDetailedInfoDto memberInfo, List childrenDtos) { return ActivityGroupBoardChildResponseDto.builder() .id(board.getId()) + .memberId(memberInfo.getMemberId()) + .memberName(memberInfo.getMemberName()) .category(board.getCategory()) .title(board.getTitle()) .content(board.getContent()) @@ -33,7 +38,7 @@ public static ActivityGroupBoardChildResponseDto toDto(ActivityGroupBoard board) .updatedAt(board.getUpdatedAt()) .createdAt(board.getCreatedAt()) .files(UploadedFileResponseDto.toDto(board.getUploadedFiles())) - .children(board.getChildren().stream().map(ActivityGroupBoardChildResponseDto::toDto).toList()) + .children(childrenDtos) .build(); } } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardResponseDto.java index 70c8d81c1..1c2e52de7 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardResponseDto.java @@ -4,6 +4,8 @@ import lombok.Getter; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoard; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoardCategory; +import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; +import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; import java.time.LocalDateTime; @@ -14,6 +16,8 @@ public class ActivityGroupBoardResponseDto { private Long id; + private String memberId; + private String memberName; private Long parentId; private ActivityGroupBoardCategory category; private String title; @@ -23,9 +27,11 @@ public class ActivityGroupBoardResponseDto { private LocalDateTime createdAt; private LocalDateTime updatedAt; - public static ActivityGroupBoardResponseDto toDto(ActivityGroupBoard board) { + public static ActivityGroupBoardResponseDto toDto(ActivityGroupBoard board, MemberDetailedInfoDto memberInfo) { return ActivityGroupBoardResponseDto.builder() .id(board.getId()) + .memberId(memberInfo.getMemberId()) + .memberName(memberInfo.getMemberName()) .parentId(board.getParent() != null ? board.getParent().getId() : null) .category(board.getCategory()) .title(board.getTitle()) @@ -36,4 +42,9 @@ public static ActivityGroupBoardResponseDto toDto(ActivityGroupBoard board) { .updatedAt(board.getUpdatedAt()) .build(); } + + public static ActivityGroupBoardResponseDto toActivityGroupBoardResponseDtoWithMemberInfo(ActivityGroupBoard activityGroupBoard, ExternalRetrieveMemberUseCase externalRetrieveMemberUseCase) { + MemberDetailedInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberDetailedInfoById(activityGroupBoard.getMemberId()); + return ActivityGroupBoardResponseDto.toDto(activityGroupBoard, memberInfo); + } } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupProjectResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupProjectResponseDto.java index f672fda7a..6d9f72cf4 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupProjectResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupProjectResponseDto.java @@ -36,7 +36,7 @@ public class ActivityGroupProjectResponseDto { private LocalDateTime createdAt; public static ActivityGroupProjectResponseDto create(ActivityGroup activityGroup, List groupMembers, - List boards, List groupMemberResponseDtos, boolean isOwner) { + List boards, List groupMemberResponseDtos, boolean isOwner) { return ActivityGroupProjectResponseDto.builder() .id(activityGroup.getId()) .category(activityGroup.getCategory()) @@ -50,7 +50,7 @@ public static ActivityGroupProjectResponseDto create(ActivityGroup activityGroup .endDate(activityGroup.getEndDate()) .techStack(activityGroup.getTechStack()) .githubUrl(activityGroup.getGithubUrl()) - .activityGroupBoards(boards.stream().map(ActivityGroupBoardResponseDto::toDto).toList()) + .activityGroupBoards(boards) .isOwner(isOwner) .createdAt(activityGroup.getCreatedAt()) .build(); diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupStudyResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupStudyResponseDto.java index 1150ec6dd..462d6200a 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupStudyResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupStudyResponseDto.java @@ -32,7 +32,7 @@ public class ActivityGroupStudyResponseDto { private LocalDateTime createdAt; public static ActivityGroupStudyResponseDto create(ActivityGroup activityGroup, List groupMembers, - List boards, List groupMemberResponseDtos, boolean isOwner) { + List boards, List groupMemberResponseDtos, boolean isOwner) { return ActivityGroupStudyResponseDto.builder() .id(activityGroup.getId()) .category(activityGroup.getCategory()) @@ -43,7 +43,7 @@ public static ActivityGroupStudyResponseDto create(ActivityGroup activityGroup, .imageUrl(activityGroup.getImageUrl()) .groupMembers(groupMemberResponseDtos) .curriculum(activityGroup.getCurriculum()) - .activityGroupBoards(boards.stream().map(ActivityGroupBoardResponseDto::toDto).toList()) + .activityGroupBoards(boards) .isOwner(isOwner) .createdAt(activityGroup.getCreatedAt()) .build(); diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AssignmentSubmissionWithFeedbackResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AssignmentSubmissionWithFeedbackResponseDto.java index bb0d931ff..e7c044776 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AssignmentSubmissionWithFeedbackResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AssignmentSubmissionWithFeedbackResponseDto.java @@ -13,6 +13,8 @@ public class AssignmentSubmissionWithFeedbackResponseDto { private Long id; + private String memberId; + private String memberName; private Long parentId; private String content; private List files; @@ -20,9 +22,11 @@ public class AssignmentSubmissionWithFeedbackResponseDto { private LocalDateTime updatedAt; private List feedbacks; - public static AssignmentSubmissionWithFeedbackResponseDto toDto(ActivityGroupBoard board, List feedbackDtos) { + public static AssignmentSubmissionWithFeedbackResponseDto toDto(ActivityGroupBoard board, String memberId, String memberName, List feedbackDtos) { return AssignmentSubmissionWithFeedbackResponseDto.builder() .id(board.getId()) + .memberId(memberId) + .memberName(memberName) .parentId(board.getParent() != null ? board.getParent().getId() : null) .content(board.getContent()) .files(UploadedFileResponseDto.toDto(board.getUploadedFiles())) diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/FeedbackResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/FeedbackResponseDto.java index 3d8ac06f1..c6f965897 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/FeedbackResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/FeedbackResponseDto.java @@ -3,6 +3,8 @@ import lombok.Builder; import lombok.Getter; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoard; +import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; +import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; import java.time.LocalDateTime; @@ -13,18 +15,27 @@ public class FeedbackResponseDto { private Long id; + private String memberId; + private String memberName; private String content; private List files; private LocalDateTime createdAt; private LocalDateTime updatedAt; - public static FeedbackResponseDto toDto(ActivityGroupBoard board) { + public static FeedbackResponseDto toDto(ActivityGroupBoard board, MemberDetailedInfoDto memberInfo) { return FeedbackResponseDto.builder() .id(board.getId()) + .memberId(memberInfo.getMemberId()) + .memberName(memberInfo.getMemberName()) .content(board.getContent()) .files(UploadedFileResponseDto.toDto(board.getUploadedFiles())) .createdAt(board.getCreatedAt()) .updatedAt(board.getUpdatedAt()) .build(); } + + public static FeedbackResponseDto toFeedbackResponseDtoWithMemberInfo(ActivityGroupBoard activityGroupBoard, ExternalRetrieveMemberUseCase externalRetrieveMemberUseCase) { + MemberDetailedInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberDetailedInfoById(activityGroupBoard.getMemberId()); + return FeedbackResponseDto.toDto(activityGroupBoard, memberInfo); + } } From 457e004b06bd1cecdc303ccc4453917724a0474f Mon Sep 17 00:00:00 2001 From: mingmingmon Date: Tue, 6 Aug 2024 15:23:52 +0900 Subject: [PATCH 2/7] =?UTF-8?q?refactor(ActivityGroupBoardController):=20?= =?UTF-8?q?=ED=99=9C=EB=8F=99=20=EA=B7=B8=EB=A3=B9=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=ED=8C=90=20=EC=83=9D=EC=84=B1=20API=20=EC=8A=A4=EC=9B=A8?= =?UTF-8?q?=EA=B1=B0=20=EC=84=A4=EB=AA=85=20=EC=B6=94=EA=B0=80=20=EB=B0=8F?= =?UTF-8?q?=20=EC=A0=9C=EC=95=BD=EC=82=AC=ED=95=AD=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?#447?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/ActivityGroupBoardController.java | 10 +++++----- .../application/ActivityGroupBoardService.java | 9 +++++++++ .../activitygroup/domain/ActivityGroupBoard.java | 1 - .../AssignmentBoardHasNoDueDateTimeException.java | 15 +++++++++++++++ .../global/handler/GlobalExceptionHandler.java | 4 +++- 5 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 src/main/java/page/clab/api/domain/activity/activitygroup/exception/AssignmentBoardHasNoDueDateTimeException.java diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupBoardController.java b/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupBoardController.java index 34e7b3a5f..e4e11e18c 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupBoardController.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/api/ActivityGroupBoardController.java @@ -42,11 +42,11 @@ public class ActivityGroupBoardController { private final PageableUtils pageableUtils; @Operation(summary = "[U] 활동 그룹 게시판 생성", description = "ROLE_USER 이상의 권한이 필요함

" + - "활동 그룹 게시판 카테고리별 requestDto에 들어가야 할 필수내용과 (선택)내용입니다.

" + - "공지사항, 주차별활동 : 카테고리, 제목, 내용, 첨부파일 경로 리스트(선택)
" + - "과제 : 부모 게시판(주차별활동), 카테고리, 제목, 내용, 마감일자, 첨부파일 경로 리스트(선택)
" + - "제출 : 부모 게시판(과제), 첨부파일 경로 리스트
" + - "피드백 : 부모 게시판(제출), 카테고리, 내용 , 첨부파일 경로 리스트(선택)" + "활동 그룹 게시판 카테고리별 requestDto에 들어가야 할 필수내용입니다.

" + + "공지사항, 주차별활동 : 카테고리
" + + "과제 : 부모 게시판(주차별활동), 카테고리, 마감일자
" + + "제출 : 부모 게시판(과제), 카테고리
" + + "피드백 : 부모 게시판(제출), 카테고리" ) @Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" }) @PostMapping("") diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java index 2a54a5dcb..5895a2e9b 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java @@ -1,5 +1,6 @@ package page.clab.api.domain.activity.activitygroup.application; +import java.time.LocalDateTime; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -19,6 +20,7 @@ import page.clab.api.domain.activity.activitygroup.dto.response.ActivityGroupBoardUpdateResponseDto; import page.clab.api.domain.activity.activitygroup.dto.response.AssignmentSubmissionWithFeedbackResponseDto; import page.clab.api.domain.activity.activitygroup.dto.response.FeedbackResponseDto; +import page.clab.api.domain.activity.activitygroup.exception.AssignmentBoardHasNoDueDateTimeException; import page.clab.api.domain.activity.activitygroup.exception.InvalidParentBoardException; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; import page.clab.api.domain.memberManagement.member.domain.Member; @@ -52,6 +54,13 @@ public Long createActivityGroupBoard(Long parentId, Long activityGroupId, Activi throw new PermissionDeniedException("활동 그룹 멤버만 게시글을 등록할 수 있습니다."); } + ActivityGroupBoardCategory activityGroupBoardCategory = requestDto.getCategory(); + LocalDateTime dueDateTime = requestDto.getDueDateTime(); + + if (activityGroupBoardCategory == ActivityGroupBoardCategory.ASSIGNMENT && dueDateTime == null) { + throw new AssignmentBoardHasNoDueDateTimeException(); + } + validateParentBoard(requestDto.getCategory(), parentId); List uploadedFiles = uploadedFileService.getUploadedFilesByUrls(requestDto.getFileUrls()); diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupBoard.java b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupBoard.java index 46df30c37..79137ba4b 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupBoard.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupBoard.java @@ -57,7 +57,6 @@ public class ActivityGroupBoard extends BaseEntity { @Enumerated(EnumType.STRING) private ActivityGroupBoardCategory category; - @Size(min = 1, max = 100, message = "{size.board.title}") private String title; @Column(columnDefinition = "TEXT") diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/exception/AssignmentBoardHasNoDueDateTimeException.java b/src/main/java/page/clab/api/domain/activity/activitygroup/exception/AssignmentBoardHasNoDueDateTimeException.java new file mode 100644 index 000000000..259fe0ccc --- /dev/null +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/exception/AssignmentBoardHasNoDueDateTimeException.java @@ -0,0 +1,15 @@ +package page.clab.api.domain.activity.activitygroup.exception; + +public class AssignmentBoardHasNoDueDateTimeException extends RuntimeException { + + private static final String DEFAULT_MESSAGE = "과제 게시판에 마감기한이 없습니다."; + + public AssignmentBoardHasNoDueDateTimeException() { + super(DEFAULT_MESSAGE); + } + + public AssignmentBoardHasNoDueDateTimeException(String s) { + super(s); + } +} + diff --git a/src/main/java/page/clab/api/global/handler/GlobalExceptionHandler.java b/src/main/java/page/clab/api/global/handler/GlobalExceptionHandler.java index b16c74e98..03d09ace9 100644 --- a/src/main/java/page/clab/api/global/handler/GlobalExceptionHandler.java +++ b/src/main/java/page/clab/api/global/handler/GlobalExceptionHandler.java @@ -26,6 +26,7 @@ import page.clab.api.domain.activity.activitygroup.exception.ActivityGroupNotFinishedException; import page.clab.api.domain.activity.activitygroup.exception.ActivityGroupNotProgressingException; import page.clab.api.domain.activity.activitygroup.exception.AlreadyAppliedException; +import page.clab.api.domain.activity.activitygroup.exception.AssignmentBoardHasNoDueDateTimeException; import page.clab.api.domain.activity.activitygroup.exception.DuplicateAbsentExcuseException; import page.clab.api.domain.activity.activitygroup.exception.DuplicateAttendanceException; import page.clab.api.domain.activity.activitygroup.exception.DuplicateReportException; @@ -98,7 +99,8 @@ public class GlobalExceptionHandler { IllegalAccessException.class, NumberFormatException.class, SortingArgumentException.class, - UnknownPathException.class + UnknownPathException.class, + AssignmentBoardHasNoDueDateTimeException.class }) public ErrorResponse badRequestException(HttpServletResponse response, Exception e) { response.setStatus(HttpServletResponse.SC_OK); From 4f5d6ba91e2d3d34195f3ff5ca715bf3734d9806 Mon Sep 17 00:00:00 2001 From: mingmingmon Date: Tue, 6 Aug 2024 15:59:51 +0900 Subject: [PATCH 3/7] =?UTF-8?q?refactor(ActivityGroupBoardService):=20?= =?UTF-8?q?=ED=99=9C=EB=8F=99=20=EA=B2=8C=EC=8B=9C=ED=8C=90=20=EC=B9=B4?= =?UTF-8?q?=ED=85=8C=EA=B3=A0=EB=A6=AC=EB=B3=84=20=EC=9C=A0=ED=9A=A8?= =?UTF-8?q?=EC=84=B1=20=EA=B2=80=EC=82=AC=20=ED=95=A8=EC=88=98=ED=99=94=20?= =?UTF-8?q?#447?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ActivityGroupBoardService.java | 26 ++++++++++++++----- .../FeedbackBoardHasNoContentException.java | 14 ++++++++++ .../handler/GlobalExceptionHandler.java | 4 ++- 3 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 src/main/java/page/clab/api/domain/activity/activitygroup/exception/FeedbackBoardHasNoContentException.java diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java index 5895a2e9b..48a08f41f 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java @@ -2,6 +2,7 @@ import java.time.LocalDateTime; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; @@ -21,6 +22,7 @@ import page.clab.api.domain.activity.activitygroup.dto.response.AssignmentSubmissionWithFeedbackResponseDto; import page.clab.api.domain.activity.activitygroup.dto.response.FeedbackResponseDto; import page.clab.api.domain.activity.activitygroup.exception.AssignmentBoardHasNoDueDateTimeException; +import page.clab.api.domain.activity.activitygroup.exception.FeedbackBoardHasNoContentException; import page.clab.api.domain.activity.activitygroup.exception.InvalidParentBoardException; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; import page.clab.api.domain.memberManagement.member.domain.Member; @@ -37,6 +39,7 @@ @Service @RequiredArgsConstructor +@Slf4j public class ActivityGroupBoardService { private final ActivityGroupBoardRepository activityGroupBoardRepository; @@ -54,14 +57,9 @@ public Long createActivityGroupBoard(Long parentId, Long activityGroupId, Activi throw new PermissionDeniedException("활동 그룹 멤버만 게시글을 등록할 수 있습니다."); } - ActivityGroupBoardCategory activityGroupBoardCategory = requestDto.getCategory(); - LocalDateTime dueDateTime = requestDto.getDueDateTime(); - - if (activityGroupBoardCategory == ActivityGroupBoardCategory.ASSIGNMENT && dueDateTime == null) { - throw new AssignmentBoardHasNoDueDateTimeException(); - } - + validateRequestBody(requestDto); validateParentBoard(requestDto.getCategory(), parentId); + List uploadedFiles = uploadedFileService.getUploadedFilesByUrls(requestDto.getFileUrls()); ActivityGroupBoard parentBoard = parentId != null ? getActivityGroupBoardByIdOrThrow(parentId) : null; @@ -202,6 +200,20 @@ private void validateParentBoard(ActivityGroupBoardCategory category, Long paren } } + private void validateRequestBody(ActivityGroupBoardRequestDto activityGroupBoardRequestDto) { + ActivityGroupBoardCategory activityGroupBoardCategory = activityGroupBoardRequestDto.getCategory(); + LocalDateTime dueDateTime = activityGroupBoardRequestDto.getDueDateTime(); + String content = activityGroupBoardRequestDto.getContent(); + + if (activityGroupBoardCategory == ActivityGroupBoardCategory.ASSIGNMENT && dueDateTime == null) { + throw new AssignmentBoardHasNoDueDateTimeException(); + } + + if (activityGroupBoardCategory == ActivityGroupBoardCategory.FEEDBACK && content.isEmpty()) { + throw new FeedbackBoardHasNoContentException(); + } + } + private void notifyMembersAboutNewBoard(Long activityGroupId, ActivityGroup activityGroup, Member member) { GroupMember groupMember = activityGroupMemberService.getGroupMemberByActivityGroupAndMemberOrThrow(activityGroup, member.getId()); if (groupMember.isLeader()) { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/exception/FeedbackBoardHasNoContentException.java b/src/main/java/page/clab/api/domain/activity/activitygroup/exception/FeedbackBoardHasNoContentException.java new file mode 100644 index 000000000..79720acc2 --- /dev/null +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/exception/FeedbackBoardHasNoContentException.java @@ -0,0 +1,14 @@ +package page.clab.api.domain.activity.activitygroup.exception; + +public class FeedbackBoardHasNoContentException extends RuntimeException { + + private static final String DEFAULT_MESSAGE = "피드백 게시판에 내용이 없습니다."; + + public FeedbackBoardHasNoContentException() { + super(DEFAULT_MESSAGE); + } + + public FeedbackBoardHasNoContentException(String s) { + super(s); + } +} \ No newline at end of file diff --git a/src/main/java/page/clab/api/global/handler/GlobalExceptionHandler.java b/src/main/java/page/clab/api/global/handler/GlobalExceptionHandler.java index 03d09ace9..4122a6a64 100644 --- a/src/main/java/page/clab/api/global/handler/GlobalExceptionHandler.java +++ b/src/main/java/page/clab/api/global/handler/GlobalExceptionHandler.java @@ -30,6 +30,7 @@ import page.clab.api.domain.activity.activitygroup.exception.DuplicateAbsentExcuseException; import page.clab.api.domain.activity.activitygroup.exception.DuplicateAttendanceException; import page.clab.api.domain.activity.activitygroup.exception.DuplicateReportException; +import page.clab.api.domain.activity.activitygroup.exception.FeedbackBoardHasNoContentException; import page.clab.api.domain.activity.activitygroup.exception.InvalidCategoryException; import page.clab.api.domain.activity.activitygroup.exception.InvalidParentBoardException; import page.clab.api.domain.activity.activitygroup.exception.LeaderStatusChangeNotAllowedException; @@ -100,7 +101,8 @@ public class GlobalExceptionHandler { NumberFormatException.class, SortingArgumentException.class, UnknownPathException.class, - AssignmentBoardHasNoDueDateTimeException.class + AssignmentBoardHasNoDueDateTimeException.class, + FeedbackBoardHasNoContentException.class }) public ErrorResponse badRequestException(HttpServletResponse response, Exception e) { response.setStatus(HttpServletResponse.SC_OK); From f133a872d221f1644a6e8b2ffaf9b29459720ce0 Mon Sep 17 00:00:00 2001 From: mingmingmon Date: Wed, 7 Aug 2024 16:07:39 +0900 Subject: [PATCH 4/7] =?UTF-8?q?refactor(activityBoardResponseDto):=20useca?= =?UTF-8?q?se=EB=A5=BC=20dto=EC=97=90=20=EC=A0=84=EB=8B=AC=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?#447?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ActivityGroupBoardService.java | 31 ++++++++++++++----- .../ActivityGroupMemberService.java | 6 +++- .../ActivityGroupBoardChildResponseDto.java | 7 +++-- .../ActivityGroupBoardResponseDto.java | 12 +++---- ...mentSubmissionWithFeedbackResponseDto.java | 7 +++-- .../dto/response/FeedbackResponseDto.java | 12 +++---- 6 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java index 48a08f41f..89067c1c6 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java @@ -24,6 +24,7 @@ import page.clab.api.domain.activity.activitygroup.exception.AssignmentBoardHasNoDueDateTimeException; import page.clab.api.domain.activity.activitygroup.exception.FeedbackBoardHasNoContentException; import page.clab.api.domain.activity.activitygroup.exception.InvalidParentBoardException; +import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberBasicInfoDto; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; import page.clab.api.domain.memberManagement.member.domain.Member; import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; @@ -77,19 +78,26 @@ public Long createActivityGroupBoard(Long parentId, Long activityGroupId, Activi @Transactional(readOnly = true) public PagedResponseDto getAllActivityGroupBoard(Pageable pageable) { Page boards = activityGroupBoardRepository.findAll(pageable); - return new PagedResponseDto<>(boards.map(board -> ActivityGroupBoardResponseDto.toActivityGroupBoardResponseDtoWithMemberInfo(board, externalRetrieveMemberUseCase))); + return new PagedResponseDto<>(boards.map(board -> { + MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById(board.getMemberId()); + return ActivityGroupBoardResponseDto.toDto(board, memberBasicInfoDto); + })); } @Transactional(readOnly = true) public ActivityGroupBoardResponseDto getActivityGroupBoardById(Long activityGroupBoardId) { ActivityGroupBoard board = getActivityGroupBoardByIdOrThrow(activityGroupBoardId); - return ActivityGroupBoardResponseDto.toActivityGroupBoardResponseDtoWithMemberInfo(board, externalRetrieveMemberUseCase); + MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById(board.getMemberId()); + return ActivityGroupBoardResponseDto.toDto(board, memberBasicInfoDto); } @Transactional(readOnly = true) public PagedResponseDto getActivityGroupBoardByCategory(Long activityGroupId, ActivityGroupBoardCategory category, Pageable pageable) { Page boards = activityGroupBoardRepository.findAllByActivityGroup_IdAndCategory(activityGroupId, category, pageable); - return new PagedResponseDto<>(boards.map(board -> ActivityGroupBoardResponseDto.toActivityGroupBoardResponseDtoWithMemberInfo(board, externalRetrieveMemberUseCase))); + return new PagedResponseDto<>(boards.map(board -> { + MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById(board.getMemberId()); + return ActivityGroupBoardResponseDto.toDto(board, memberBasicInfoDto); + })); } @Transactional(readOnly = true) @@ -115,9 +123,13 @@ public List getMyAssignmentsWithFee .map(submission -> { List feedbackDtos = submission.getChildren().stream() .filter(ActivityGroupBoard::isFeedback) - .map(board -> FeedbackResponseDto.toFeedbackResponseDtoWithMemberInfo(board, externalRetrieveMemberUseCase)) + .map(board -> { + MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById(board.getMemberId()); + return FeedbackResponseDto.toDto(board, memberBasicInfoDto); + }) .toList(); - return AssignmentSubmissionWithFeedbackResponseDto.toDto(submission, currentMember.getId(), currentMember.getName(), feedbackDtos); + MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById(submission.getMemberId()); + return AssignmentSubmissionWithFeedbackResponseDto.toDto(submission, memberBasicInfoDto, feedbackDtos); }) .toList(); } @@ -144,7 +156,10 @@ public Long deleteActivityGroupBoard(Long activityGroupBoardId) throws Permissio @Transactional(readOnly = true) public PagedResponseDto getDeletedActivityGroupBoards(Pageable pageable) { Page boards = activityGroupBoardRepository.findAllByIsDeletedTrue(pageable); - return new PagedResponseDto<>(boards.map(board -> ActivityGroupBoardResponseDto.toActivityGroupBoardResponseDtoWithMemberInfo(board, externalRetrieveMemberUseCase))); + return new PagedResponseDto<>(boards.map(board -> { + MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getMemberBasicInfoById(board.getMemberId()); + return ActivityGroupBoardResponseDto.toDto(board, memberBasicInfoDto); + })); } private ActivityGroupBoard getActivityGroupBoardByIdOrThrow(Long activityGroupBoardId) { @@ -160,11 +175,11 @@ private List getChildBoards(Long activityGroupBoardId) { } public ActivityGroupBoardChildResponseDto toActivityGroupBoardChildResponseDtoWithMemberInfo(ActivityGroupBoard activityGroupBoard) { - MemberDetailedInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberDetailedInfoById(activityGroupBoard.getMemberId()); + MemberBasicInfoDto memberBasicInfo = externalRetrieveMemberUseCase.getMemberBasicInfoById(activityGroupBoard.getMemberId()); List childrenDtos = activityGroupBoard.getChildren().stream() .map(child -> toActivityGroupBoardChildResponseDtoWithMemberInfo(child)) .toList(); - return ActivityGroupBoardChildResponseDto.toDto(activityGroupBoard, memberInfo, childrenDtos); + return ActivityGroupBoardChildResponseDto.toDto(activityGroupBoard, memberBasicInfo, childrenDtos); } private void validateParentBoard(ActivityGroupBoardCategory category, Long parentId) throws InvalidParentBoardException { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupMemberService.java b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupMemberService.java index 235ab314d..af334f5ff 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupMemberService.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupMemberService.java @@ -31,6 +31,7 @@ import page.clab.api.domain.activity.activitygroup.dto.response.GroupMemberResponseDto; import page.clab.api.domain.activity.activitygroup.exception.AlreadyAppliedException; import page.clab.api.domain.activity.activitygroup.exception.InvalidCategoryException; +import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberBasicInfoDto; import page.clab.api.domain.memberManagement.member.domain.Member; import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.external.memberManagement.notification.application.port.ExternalSendNotificationUseCase; @@ -72,7 +73,10 @@ public Object getActivityGroup(Long activityGroupId) { List activityGroupResponseDtos = details.getActivityGroupBoards().stream() - .map(board -> ActivityGroupBoardResponseDto.toActivityGroupBoardResponseDtoWithMemberInfo(board, externalRetrieveMemberUseCase)) + .map(board -> { + MemberBasicInfoDto memberBasicInfoDto = externalRetrieveMemberUseCase.getCurrentMemberBasicInfo(); + return ActivityGroupBoardResponseDto.toDto(board, memberBasicInfoDto); + }) .toList(); if (details.getActivityGroup().isStudy()) { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardChildResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardChildResponseDto.java index c0ed5fb9d..dd2ecbb84 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardChildResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardChildResponseDto.java @@ -4,6 +4,7 @@ import lombok.Getter; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoard; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoardCategory; +import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberBasicInfoDto; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; @@ -26,11 +27,11 @@ public class ActivityGroupBoardChildResponseDto { private List files; private List children; - public static ActivityGroupBoardChildResponseDto toDto(ActivityGroupBoard board, MemberDetailedInfoDto memberInfo, List childrenDtos) { + public static ActivityGroupBoardChildResponseDto toDto(ActivityGroupBoard board, MemberBasicInfoDto memberBasicInfoDto, List childrenDtos) { return ActivityGroupBoardChildResponseDto.builder() .id(board.getId()) - .memberId(memberInfo.getMemberId()) - .memberName(memberInfo.getMemberName()) + .memberId(memberBasicInfoDto.getMemberId()) + .memberName(memberBasicInfoDto.getMemberName()) .category(board.getCategory()) .title(board.getTitle()) .content(board.getContent()) diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardResponseDto.java index 1c2e52de7..200c9b001 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/ActivityGroupBoardResponseDto.java @@ -4,6 +4,7 @@ import lombok.Getter; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoard; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoardCategory; +import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberBasicInfoDto; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; @@ -27,11 +28,11 @@ public class ActivityGroupBoardResponseDto { private LocalDateTime createdAt; private LocalDateTime updatedAt; - public static ActivityGroupBoardResponseDto toDto(ActivityGroupBoard board, MemberDetailedInfoDto memberInfo) { + public static ActivityGroupBoardResponseDto toDto(ActivityGroupBoard board, MemberBasicInfoDto memberBasicInfoDto) { return ActivityGroupBoardResponseDto.builder() .id(board.getId()) - .memberId(memberInfo.getMemberId()) - .memberName(memberInfo.getMemberName()) + .memberId(memberBasicInfoDto.getMemberId()) + .memberName(memberBasicInfoDto.getMemberName()) .parentId(board.getParent() != null ? board.getParent().getId() : null) .category(board.getCategory()) .title(board.getTitle()) @@ -42,9 +43,4 @@ public static ActivityGroupBoardResponseDto toDto(ActivityGroupBoard board, Memb .updatedAt(board.getUpdatedAt()) .build(); } - - public static ActivityGroupBoardResponseDto toActivityGroupBoardResponseDtoWithMemberInfo(ActivityGroupBoard activityGroupBoard, ExternalRetrieveMemberUseCase externalRetrieveMemberUseCase) { - MemberDetailedInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberDetailedInfoById(activityGroupBoard.getMemberId()); - return ActivityGroupBoardResponseDto.toDto(activityGroupBoard, memberInfo); - } } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AssignmentSubmissionWithFeedbackResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AssignmentSubmissionWithFeedbackResponseDto.java index e7c044776..f8dcbbc67 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AssignmentSubmissionWithFeedbackResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/AssignmentSubmissionWithFeedbackResponseDto.java @@ -3,6 +3,7 @@ import lombok.Builder; import lombok.Getter; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoard; +import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberBasicInfoDto; import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; import java.time.LocalDateTime; @@ -22,11 +23,11 @@ public class AssignmentSubmissionWithFeedbackResponseDto { private LocalDateTime updatedAt; private List feedbacks; - public static AssignmentSubmissionWithFeedbackResponseDto toDto(ActivityGroupBoard board, String memberId, String memberName, List feedbackDtos) { + public static AssignmentSubmissionWithFeedbackResponseDto toDto(ActivityGroupBoard board, MemberBasicInfoDto memberBasicInfo, List feedbackDtos) { return AssignmentSubmissionWithFeedbackResponseDto.builder() .id(board.getId()) - .memberId(memberId) - .memberName(memberName) + .memberId(memberBasicInfo.getMemberId()) + .memberName(memberBasicInfo.getMemberName()) .parentId(board.getParent() != null ? board.getParent().getId() : null) .content(board.getContent()) .files(UploadedFileResponseDto.toDto(board.getUploadedFiles())) diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/FeedbackResponseDto.java b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/FeedbackResponseDto.java index c6f965897..021b242e2 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/FeedbackResponseDto.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/dto/response/FeedbackResponseDto.java @@ -3,6 +3,7 @@ import lombok.Builder; import lombok.Getter; import page.clab.api.domain.activity.activitygroup.domain.ActivityGroupBoard; +import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberBasicInfoDto; import page.clab.api.domain.memberManagement.member.application.dto.shared.MemberDetailedInfoDto; import page.clab.api.external.memberManagement.member.application.port.ExternalRetrieveMemberUseCase; import page.clab.api.global.common.file.dto.response.UploadedFileResponseDto; @@ -22,20 +23,15 @@ public class FeedbackResponseDto { private LocalDateTime createdAt; private LocalDateTime updatedAt; - public static FeedbackResponseDto toDto(ActivityGroupBoard board, MemberDetailedInfoDto memberInfo) { + public static FeedbackResponseDto toDto(ActivityGroupBoard board, MemberBasicInfoDto memberBasicInfo) { return FeedbackResponseDto.builder() .id(board.getId()) - .memberId(memberInfo.getMemberId()) - .memberName(memberInfo.getMemberName()) + .memberId(memberBasicInfo.getMemberId()) + .memberName(memberBasicInfo.getMemberName()) .content(board.getContent()) .files(UploadedFileResponseDto.toDto(board.getUploadedFiles())) .createdAt(board.getCreatedAt()) .updatedAt(board.getUpdatedAt()) .build(); } - - public static FeedbackResponseDto toFeedbackResponseDtoWithMemberInfo(ActivityGroupBoard activityGroupBoard, ExternalRetrieveMemberUseCase externalRetrieveMemberUseCase) { - MemberDetailedInfoDto memberInfo = externalRetrieveMemberUseCase.getMemberDetailedInfoById(activityGroupBoard.getMemberId()); - return FeedbackResponseDto.toDto(activityGroupBoard, memberInfo); - } } From f1e8a0acde9141b90cf6c6ce9a44f1e5d7ed816f Mon Sep 17 00:00:00 2001 From: mingmingmon Date: Wed, 7 Aug 2024 16:27:02 +0900 Subject: [PATCH 5/7] =?UTF-8?q?refactor(ActivityGroupBoardService):=20vali?= =?UTF-8?q?dateRequestBody=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC=20=EB=B0=8F=20=EB=A9=94=EC=86=8C=EB=93=9C=EB=AA=85=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#447?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ActivityGroupBoardService.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java index 89067c1c6..0474c40f6 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java @@ -57,8 +57,13 @@ public Long createActivityGroupBoard(Long parentId, Long activityGroupId, Activi if (!activityGroupMemberService.isGroupMember(activityGroup, currentMember.getId())) { throw new PermissionDeniedException("활동 그룹 멤버만 게시글을 등록할 수 있습니다."); } + if (requestDto.getCategory() == ActivityGroupBoardCategory.ASSIGNMENT) { + validateDueDateForAssignment(requestDto); + } + if (requestDto.getCategory() == ActivityGroupBoardCategory.FEEDBACK) { + validateContentForFeedback(requestDto); + } - validateRequestBody(requestDto); validateParentBoard(requestDto.getCategory(), parentId); List uploadedFiles = uploadedFileService.getUploadedFilesByUrls(requestDto.getFileUrls()); @@ -215,16 +220,16 @@ private void validateParentBoard(ActivityGroupBoardCategory category, Long paren } } - private void validateRequestBody(ActivityGroupBoardRequestDto activityGroupBoardRequestDto) { - ActivityGroupBoardCategory activityGroupBoardCategory = activityGroupBoardRequestDto.getCategory(); + private void validateDueDateForAssignment(ActivityGroupBoardRequestDto activityGroupBoardRequestDto) { LocalDateTime dueDateTime = activityGroupBoardRequestDto.getDueDateTime(); - String content = activityGroupBoardRequestDto.getContent(); - - if (activityGroupBoardCategory == ActivityGroupBoardCategory.ASSIGNMENT && dueDateTime == null) { + if (dueDateTime == null) { throw new AssignmentBoardHasNoDueDateTimeException(); } + } - if (activityGroupBoardCategory == ActivityGroupBoardCategory.FEEDBACK && content.isEmpty()) { + private void validateContentForFeedback(ActivityGroupBoardRequestDto activityGroupBoardRequestDto) { + String content = activityGroupBoardRequestDto.getContent(); + if (content.isEmpty()) { throw new FeedbackBoardHasNoContentException(); } } From deee4e3acf8260445ea2b9a7b8cea79dab183121 Mon Sep 17 00:00:00 2001 From: mingmingmon Date: Sun, 11 Aug 2024 14:53:59 +0900 Subject: [PATCH 6/7] =?UTF-8?q?refactor(ActivityGroupBoard):=20=EC=B9=B4?= =?UTF-8?q?=ED=85=8C=EA=B3=A0=EB=A6=AC=EC=97=90=20=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=ED=95=84=EC=88=98=20=EC=9A=94=EC=86=8C=20=EA=B2=80=EC=A6=9D=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EB=8F=84=EB=A9=94=EC=9D=B8=20=EA=B0=9D?= =?UTF-8?q?=EC=B2=B4=EB=A1=9C=20=EC=9D=B4=EB=8F=99=20#447?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ActivityGroupBoardService.java | 22 ++----------------- .../domain/ActivityGroupBoard.java | 18 +++++++++++++++ .../common/file/api/FileController.java | 1 + .../common/file/application/FileService.java | 10 +++++++++ 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java index 0474c40f6..f7a2c7f91 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupBoardService.java @@ -57,12 +57,6 @@ public Long createActivityGroupBoard(Long parentId, Long activityGroupId, Activi if (!activityGroupMemberService.isGroupMember(activityGroup, currentMember.getId())) { throw new PermissionDeniedException("활동 그룹 멤버만 게시글을 등록할 수 있습니다."); } - if (requestDto.getCategory() == ActivityGroupBoardCategory.ASSIGNMENT) { - validateDueDateForAssignment(requestDto); - } - if (requestDto.getCategory() == ActivityGroupBoardCategory.FEEDBACK) { - validateContentForFeedback(requestDto); - } validateParentBoard(requestDto.getCategory(), parentId); @@ -70,6 +64,8 @@ public Long createActivityGroupBoard(Long parentId, Long activityGroupId, Activi ActivityGroupBoard parentBoard = parentId != null ? getActivityGroupBoardByIdOrThrow(parentId) : null; ActivityGroupBoard board = ActivityGroupBoardRequestDto.toEntity(requestDto, currentMember, activityGroup, parentBoard, uploadedFiles); + board.validateEssentialElementByCategory(); + if (parentId != null) { parentBoard.addChild(board); activityGroupBoardRepository.save(parentBoard); @@ -220,20 +216,6 @@ private void validateParentBoard(ActivityGroupBoardCategory category, Long paren } } - private void validateDueDateForAssignment(ActivityGroupBoardRequestDto activityGroupBoardRequestDto) { - LocalDateTime dueDateTime = activityGroupBoardRequestDto.getDueDateTime(); - if (dueDateTime == null) { - throw new AssignmentBoardHasNoDueDateTimeException(); - } - } - - private void validateContentForFeedback(ActivityGroupBoardRequestDto activityGroupBoardRequestDto) { - String content = activityGroupBoardRequestDto.getContent(); - if (content.isEmpty()) { - throw new FeedbackBoardHasNoContentException(); - } - } - private void notifyMembersAboutNewBoard(Long activityGroupId, ActivityGroup activityGroup, Member member) { GroupMember groupMember = activityGroupMemberService.getGroupMemberByActivityGroupAndMemberOrThrow(activityGroup, member.getId()); if (groupMember.isLeader()) { diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupBoard.java b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupBoard.java index 79137ba4b..787730469 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupBoard.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroupBoard.java @@ -20,7 +20,10 @@ import lombok.Setter; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLRestriction; +import page.clab.api.domain.activity.activitygroup.dto.request.ActivityGroupBoardRequestDto; import page.clab.api.domain.activity.activitygroup.dto.request.ActivityGroupBoardUpdateRequestDto; +import page.clab.api.domain.activity.activitygroup.exception.AssignmentBoardHasNoDueDateTimeException; +import page.clab.api.domain.activity.activitygroup.exception.FeedbackBoardHasNoContentException; import page.clab.api.domain.memberManagement.member.domain.Member; import page.clab.api.global.common.domain.BaseEntity; import page.clab.api.global.common.file.application.UploadedFileService; @@ -115,4 +118,19 @@ public void validateAccessPermission(Member member, GroupMember leader) throws P } } } + + public void validateEssentialElementByCategory() { + if (this.isAssignment()) { + LocalDateTime dueDateTime = this.getDueDateTime(); + if (dueDateTime == null) { + throw new AssignmentBoardHasNoDueDateTimeException(); + } + } + if (this.isFeedback()) { + String content = this.getContent(); + if (content.isEmpty()) { + throw new FeedbackBoardHasNoContentException(); + } + } + } } diff --git a/src/main/java/page/clab/api/global/common/file/api/FileController.java b/src/main/java/page/clab/api/global/common/file/api/FileController.java index 431961018..4ea625c98 100644 --- a/src/main/java/page/clab/api/global/common/file/api/FileController.java +++ b/src/main/java/page/clab/api/global/common/file/api/FileController.java @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import page.clab.api.global.common.dto.ApiResponse; diff --git a/src/main/java/page/clab/api/global/common/file/application/FileService.java b/src/main/java/page/clab/api/global/common/file/application/FileService.java index f29e90e1a..7d4979212 100644 --- a/src/main/java/page/clab/api/global/common/file/application/FileService.java +++ b/src/main/java/page/clab/api/global/common/file/application/FileService.java @@ -64,6 +64,16 @@ public String saveQRCodeImage(byte[] QRCodeImage, String path, long storagePerio return url; } + public List saveFilesTest(MultipartFile[] multipartFiles, String path, long storagePeriod) throws IOException, PermissionDeniedException { + List uploadedFileResponseDtos = new ArrayList<>(); + for (MultipartFile multipartFile : multipartFiles) { + UploadedFileResponseDto responseDto = saveFile(multipartFile, path, storagePeriod); + uploadedFileResponseDtos.add(responseDto); + } + return uploadedFileResponseDtos; + } + + public List saveFiles(List multipartFiles, String path, long storagePeriod) throws IOException, PermissionDeniedException { List uploadedFileResponseDtos = new ArrayList<>(); for (MultipartFile multipartFile : multipartFiles) { From 26fd94e5d821ff8b80e0ed9128fc13fdd2f8a100 Mon Sep 17 00:00:00 2001 From: mingmingmon Date: Sun, 11 Aug 2024 15:00:07 +0900 Subject: [PATCH 7/7] =?UTF-8?q?refactor(File):=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EA=B3=BC=20=EA=B4=80=EB=A0=A8=20=EC=97=86=EB=8A=94=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=A1=A4=EB=B0=B1=20#447?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/global/common/file/api/FileController.java | 1 - .../global/common/file/application/FileService.java | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/src/main/java/page/clab/api/global/common/file/api/FileController.java b/src/main/java/page/clab/api/global/common/file/api/FileController.java index 4ea625c98..431961018 100644 --- a/src/main/java/page/clab/api/global/common/file/api/FileController.java +++ b/src/main/java/page/clab/api/global/common/file/api/FileController.java @@ -11,7 +11,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import page.clab.api.global.common.dto.ApiResponse; diff --git a/src/main/java/page/clab/api/global/common/file/application/FileService.java b/src/main/java/page/clab/api/global/common/file/application/FileService.java index 7d4979212..f29e90e1a 100644 --- a/src/main/java/page/clab/api/global/common/file/application/FileService.java +++ b/src/main/java/page/clab/api/global/common/file/application/FileService.java @@ -64,16 +64,6 @@ public String saveQRCodeImage(byte[] QRCodeImage, String path, long storagePerio return url; } - public List saveFilesTest(MultipartFile[] multipartFiles, String path, long storagePeriod) throws IOException, PermissionDeniedException { - List uploadedFileResponseDtos = new ArrayList<>(); - for (MultipartFile multipartFile : multipartFiles) { - UploadedFileResponseDto responseDto = saveFile(multipartFile, path, storagePeriod); - uploadedFileResponseDtos.add(responseDto); - } - return uploadedFileResponseDtos; - } - - public List saveFiles(List multipartFiles, String path, long storagePeriod) throws IOException, PermissionDeniedException { List uploadedFileResponseDtos = new ArrayList<>(); for (MultipartFile multipartFile : multipartFiles) {