Skip to content

Commit

Permalink
refactor(ActivityGroupBoardService): validateRequestBody 메소드 분리 및 메소드…
Browse files Browse the repository at this point in the history
…명 수정 #447
  • Loading branch information
mingmingmon committed Aug 7, 2024
1 parent f133a87 commit f1e8a0a
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<UploadedFile> uploadedFiles = uploadedFileService.getUploadedFilesByUrls(requestDto.getFileUrls());
Expand Down Expand Up @@ -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();
}
}
Expand Down

0 comments on commit f1e8a0a

Please sign in to comment.