From bcea14e71a8212883be7d9e0b165737b5ff525b2 Mon Sep 17 00:00:00 2001 From: mingmingmon Date: Sun, 8 Sep 2024 21:03:01 +0900 Subject: [PATCH] =?UTF-8?q?refactor(ActivityGroup):=20=ED=99=9C=EB=8F=99?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1=20=EC=8B=9C=20=EB=82=B4=EC=9A=A9=EA=B3=BC?= =?UTF-8?q?=20=EC=BB=A4=EB=A6=AC=ED=81=98=EB=9F=BC=EC=9D=98=20=EA=B8=80?= =?UTF-8?q?=EC=9E=90=20=EC=88=98=20=EC=A0=9C=ED=95=9C=201000=EC=9E=90?= =?UTF-8?q?=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ActivityGroupAdminService.java | 1 + .../activitygroup/domain/ActivityGroup.java | 30 ++++++++++++++----- .../CurriculumLengthExceededException.java | 8 +++++ .../handler/GlobalExceptionHandler.java | 2 ++ src/main/resources/messages.properties | 1 + 5 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 src/main/java/page/clab/api/domain/activity/activitygroup/exception/CurriculumLengthExceededException.java diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupAdminService.java b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupAdminService.java index 0afc5a80a..15d7995a2 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupAdminService.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/application/ActivityGroupAdminService.java @@ -55,6 +55,7 @@ public Long createActivityGroup(ActivityGroupRequestDto requestDto) { Member currentMember = externalRetrieveMemberUseCase.getCurrentMember(); ActivityGroup activityGroup = ActivityGroupRequestDto.toEntity(requestDto); activityGroup.validateContentLength(); + activityGroup.validateCurriculumLength(); activityGroup.validateAndSetGithubUrl(activityGroup.getGithubUrl()); activityGroupRepository.save(activityGroup); diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroup.java b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroup.java index 982fce462..1c3b682e4 100644 --- a/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroup.java +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/domain/ActivityGroup.java @@ -20,6 +20,7 @@ import page.clab.api.domain.activity.activitygroup.dto.request.ActivityGroupUpdateRequestDto; import page.clab.api.domain.activity.activitygroup.exception.ActivityGroupNotProgressingException; import page.clab.api.domain.activity.activitygroup.exception.ContentLengthExceededException; +import page.clab.api.domain.activity.activitygroup.exception.CurriculumLengthExceededException; import page.clab.api.domain.activity.activitygroup.exception.InvalidGithubUrlException; import page.clab.api.global.common.domain.BaseEntity; @@ -51,8 +52,8 @@ public class ActivityGroup extends BaseEntity { @Size(min = 1, max = 30, message = "{size.activityGroup.name}") private String name; - @Column(nullable = false, length = 200) - @Size(min = 1, max = 200, message = "{size.activityGroup.content}") + @Column(nullable = false, length = 1000) + @Size(min = 1, max = 1000, message = "{size.activityGroup.content}") private String content; @Column(nullable = false) @@ -64,6 +65,8 @@ public class ActivityGroup extends BaseEntity { private String imageUrl; + @Column(length = 1000) + @Size(min = 1, max = 1000, message = "{size.activityGroup.curriculum}") private String curriculum; private LocalDate startDate; @@ -83,7 +86,7 @@ public void update(ActivityGroupUpdateRequestDto requestDto) { Optional.ofNullable(requestDto.getName()).ifPresent(this::setName); Optional.ofNullable(requestDto.getContent()).ifPresent(this::validateAndSetContentLength); Optional.ofNullable(requestDto.getImageUrl()).ifPresent(this::setImageUrl); - Optional.ofNullable(requestDto.getCurriculum()).ifPresent(this::setCurriculum); + Optional.ofNullable(requestDto.getCurriculum()).ifPresent(this::validateAndSetCurriculumLength); Optional.ofNullable(requestDto.getStartDate()).ifPresent(this::setStartDate); Optional.ofNullable(requestDto.getEndDate()).ifPresent(this::setEndDate); Optional.ofNullable(requestDto.getTechStack()).ifPresent(this::setTechStack); @@ -116,15 +119,28 @@ public void validateForApplication() { } } + public void validateCurriculumLength() { + if (this.curriculum != null && this.curriculum.length() > 1000) { + throw new CurriculumLengthExceededException("활동 커리큘럼은 1000자 이하여야 합니다."); + } + } + + public void validateAndSetCurriculumLength(String curriculum) { + if (curriculum != null && curriculum.length() > 1000) { + throw new CurriculumLengthExceededException("활동 커리큘럼은 1000자 이하여야 합니다."); + } + this.curriculum = curriculum; + } + public void validateContentLength() { - if (this.content != null && this.content.length() > 200) { - throw new ContentLengthExceededException("활동 설명은 200자 이하여야 합니다."); + if (this.content != null && this.content.length() > 1000) { + throw new ContentLengthExceededException("활동 설명은 1000자 이하여야 합니다."); } } public void validateAndSetContentLength(String content) { - if (content != null && content.length() > 200) { - throw new ContentLengthExceededException("활동 설명은 200자 이하여야 합니다."); + if (content != null && content.length() > 1000) { + throw new ContentLengthExceededException("활동 설명은 1000자 이하여야 합니다."); } this.content = content; } diff --git a/src/main/java/page/clab/api/domain/activity/activitygroup/exception/CurriculumLengthExceededException.java b/src/main/java/page/clab/api/domain/activity/activitygroup/exception/CurriculumLengthExceededException.java new file mode 100644 index 000000000..238681f26 --- /dev/null +++ b/src/main/java/page/clab/api/domain/activity/activitygroup/exception/CurriculumLengthExceededException.java @@ -0,0 +1,8 @@ +package page.clab.api.domain.activity.activitygroup.exception; + +public class CurriculumLengthExceededException extends RuntimeException { + + public CurriculumLengthExceededException(String message) { + super(message); + } +} \ 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 f120530c5..558f3f875 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.AlreadySubmittedThisWeekAssignmentException; import page.clab.api.domain.activity.activitygroup.exception.AssignmentBoardHasNoDueDateTimeException; import page.clab.api.domain.activity.activitygroup.exception.ContentLengthExceededException; +import page.clab.api.domain.activity.activitygroup.exception.CurriculumLengthExceededException; 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; @@ -127,6 +128,7 @@ public class GlobalExceptionHandler { AssignmentBoardHasNoDueDateTimeException.class, FeedbackBoardHasNoContentException.class, ContentLengthExceededException.class, + CurriculumLengthExceededException.class }) public ErrorResponse badRequestException(HttpServletResponse response, Exception e) { response.setStatus(HttpServletResponse.SC_OK); diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index e07596f6a..aba9cfbb8 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -1,6 +1,7 @@ size.accuse.reason=신고 사유는 {min}자 이상 {max}자 이하로 입력하세요. size.activityGroup.name=이름은 {min}자 이상 {max}자 이하로 입력하세요. size.activityGroup.content=내용은 {min}자 이상 {max}자 이하로 입력하세요. +size.activityGroup.curriculum=커리큘럼은 {min}자 이상 {max}자 이하로 입력하세요. size.activityGroupBoard.title=제목은 {min}자 이상 {max}자 이하로 입력하세요. size.application.studentId=학번은 {min}자 이상 {max}자 이하로 입력하세요. size.application.name=이름은 {min}자 이상 {max}자 이하로 입력하세요.