Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/206 봉사활동 모집글 수정 기능 수정 #207

Merged
merged 2 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public boolean isRecruitOpen() {

private void updateRecruitmentInfo(RecruitBoardUpdateRequestDto dto) {
recruitmentInfo.updateWith(
dto.region(),
dto.recruitmentCount(),
dto.volunteerCategory(),
dto.volunteerStartDateTime(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ public LocalTime calculateVolunteerTime() {
return LocalTime.of((int) hours, (int) minutes);
}

public void updateWith(Integer recruitmentCount, VolunteerCategory volunteerCategory,
public void updateWith(String region, Integer recruitmentCount, VolunteerCategory volunteerCategory,
LocalDateTime volunteerStartDateTime, LocalDateTime volunteerEndDateTime,
Boolean admitted) {

validateVolunteerDateTime(volunteerStartDateTime, volunteerEndDateTime);

this.region = region;
this.recruitmentCount = recruitmentCount;
this.volunteerCategory = volunteerCategory;
this.volunteerStartDateTime = volunteerStartDateTime.truncatedTo(MINUTES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public record RecruitBoardCreateRequestDto(
@Schema(description = "봉사 모집글 내용", example = "서울 청계천 주변 환경 미화 봉사 모집합니다. <br>")
@NotBlank(message = "모집글 내용은 필수 값입니다.")
String content,
@Schema(description = "봉사 지역", example = "서울")
@Schema(description = "봉사 지역", example = "서울특별시")
@NotBlank(message = "봉사 지역은 필수 값입니다.")
String region,
@Schema(description = "예상 모집 인원", example = "4")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ public record RecruitBoardUpdateRequestDto(
@Schema(description = "봉사 모집글 내용", example = "서울 청계천 주변 환경 미화 봉사 모집합니다. <br>")
@NotBlank(message = "모집글 내용은 필수 값입니다.")
String content,
@Schema(description = "봉사 지역", example = "서울특별시")
@NotBlank(message = "봉사 지역은 필수 값입니다.")
String region,
@Schema(description = "예상 모집 인원", example = "4")
@NotNull(message = "예상 모집 인원은 필수 값입니다.")
Integer recruitmentCount,
@Schema(description = "봉사 시작 일시", example = "2024-11-20T10:00:00", type = "string")
@Schema(description = "봉사 시작 일시", example = "2024-12-20T10:00:00", type = "string")
@NotNull(message = "봉사 시작 일시는 필수 값입니다.")
@Future(message = "봉사 시작 일시는 내일부터 가능합니다.")
LocalDateTime volunteerStartDateTime,
@Schema(description = "봉사 종료 일시", example = "2024-11-20T12:00:00", type = "string")
@Schema(description = "봉사 종료 일시", example = "2024-12-20T12:00:00", type = "string")
@NotNull(message = "봉사 종료 일시는 필수 값입니다.")
@Future(message = "봉사 종료 일시는 내일부터 가능합니다.")LocalDateTime volunteerEndDateTime,
@Schema(description = "봉사 활동 유형", example = "ENVIRONMENTAL_PROTECTION")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ void updateRecruitBoard() throws Exception {
RecruitBoardUpdateRequestDto requestDto = RecruitBoardUpdateRequestDto.builder()
.title("서울 청계천 환경 미화 봉사 모집")
.content("서울 청계천 주변 환경 미화 봉사 모집합니다. <br>")
.region("서울 특별시")
.recruitmentCount(10)
.volunteerStartDateTime(startDateTime)
.volunteerEndDateTime(endDateTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ void updateRecruitmentInfo() {
// given
RecruitmentInfo recruitmentInfo = createRecruitmentInfo();

String region = "서울특별시";
Integer count = 2;
VolunteerCategory volunteerCategory = SAFETY_PREVENTION;
LocalDateTime startDateTime = createUpdateStartDateTime();
LocalDateTime endDateTime = startDateTime.plusHours(2);
Boolean admitted = false;

// when
recruitmentInfo.updateWith(count, volunteerCategory, startDateTime,
recruitmentInfo.updateWith(region, count, volunteerCategory, startDateTime,
endDateTime, admitted);

// then
Expand Down Expand Up @@ -99,7 +100,7 @@ void updateRecruitBoardWithInValidVolunteerTime(long minutesOffset) {

// when & then
assertThatThrownBy(
() -> recruitmentInfo.updateWith(3, ADMINISTRATIVE_SUPPORT, startDateTime, endDateTime,
() -> recruitmentInfo.updateWith("",3, ADMINISTRATIVE_SUPPORT, startDateTime, endDateTime,
false)
).isInstanceOf(IllegalArgumentException.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ void updateRecruitBoard() {
LocalDateTime newEndDateTime = newStartDateTime.plusHours(3);
String newImgUrl = "https://image.domain.com/updates";
RecruitBoardUpdateRequestDto dto = RecruitBoardUpdateRequestDto.builder()
.title("업데이트 제목")
.content("업데이트 내용")
.recruitmentCount(1111)
.volunteerStartDateTime(newStartDateTime)
.volunteerEndDateTime(newEndDateTime)
.volunteerCategory(ADMINISTRATIVE_SUPPORT)
.admitted(false)
.build();
.title("업데이트 제목")
.content("업데이트 내용")
.recruitmentCount(1111)
.region("서울특별시")
.volunteerStartDateTime(newStartDateTime)
.volunteerEndDateTime(newEndDateTime)
.volunteerCategory(ADMINISTRATIVE_SUPPORT)
.admitted(false)
.build();

// when
updateRecruitBoardService.updateRecruitBoard(dto, recruitBoard.getId(), centerId,
Expand Down
Loading