Skip to content

Commit

Permalink
refactor(ActivityGroup): 활동 생성 시 내용과 커리큘럼의 글자 수 제한 1000자로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
mingmingmon committed Sep 8, 2024
1 parent c6c4fce commit bcea14e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package page.clab.api.domain.activity.activitygroup.exception;

public class CurriculumLengthExceededException extends RuntimeException {

public CurriculumLengthExceededException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -127,6 +128,7 @@ public class GlobalExceptionHandler {
AssignmentBoardHasNoDueDateTimeException.class,
FeedbackBoardHasNoContentException.class,
ContentLengthExceededException.class,
CurriculumLengthExceededException.class
})
public ErrorResponse<Exception> badRequestException(HttpServletResponse response, Exception e) {
response.setStatus(HttpServletResponse.SC_OK);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages.properties
Original file line number Diff line number Diff line change
@@ -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}자 이하로 입력하세요.
Expand Down

0 comments on commit bcea14e

Please sign in to comment.