Skip to content

Commit ce6cda5

Browse files
authored
refactor: 봉사활동 모집글 수정 기능 수정 (#207)
* feat(recruit-board): 모집글 수정 기능 변경 - region 필드 추가 * test(recruit-board): 모집글 수정 기능 변경에 따른 테스트 - region 필드 추가
1 parent dcf61b0 commit ce6cda5

File tree

7 files changed

+22
-14
lines changed

7 files changed

+22
-14
lines changed

src/main/java/com/somemore/recruitboard/domain/RecruitBoard.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public boolean isRecruitOpen() {
9999

100100
private void updateRecruitmentInfo(RecruitBoardUpdateRequestDto dto) {
101101
recruitmentInfo.updateWith(
102+
dto.region(),
102103
dto.recruitmentCount(),
103104
dto.volunteerCategory(),
104105
dto.volunteerStartDateTime(),

src/main/java/com/somemore/recruitboard/domain/RecruitmentInfo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,13 @@ public LocalTime calculateVolunteerTime() {
6262
return LocalTime.of((int) hours, (int) minutes);
6363
}
6464

65-
public void updateWith(Integer recruitmentCount, VolunteerCategory volunteerCategory,
65+
public void updateWith(String region, Integer recruitmentCount, VolunteerCategory volunteerCategory,
6666
LocalDateTime volunteerStartDateTime, LocalDateTime volunteerEndDateTime,
6767
Boolean admitted) {
6868

6969
validateVolunteerDateTime(volunteerStartDateTime, volunteerEndDateTime);
7070

71+
this.region = region;
7172
this.recruitmentCount = recruitmentCount;
7273
this.volunteerCategory = volunteerCategory;
7374
this.volunteerStartDateTime = volunteerStartDateTime.truncatedTo(MINUTES);

src/main/java/com/somemore/recruitboard/dto/request/RecruitBoardCreateRequestDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public record RecruitBoardCreateRequestDto(
2323
@Schema(description = "봉사 모집글 내용", example = "서울 청계천 주변 환경 미화 봉사 모집합니다. <br>")
2424
@NotBlank(message = "모집글 내용은 필수 값입니다.")
2525
String content,
26-
@Schema(description = "봉사 지역", example = "서울")
26+
@Schema(description = "봉사 지역", example = "서울특별시")
2727
@NotBlank(message = "봉사 지역은 필수 값입니다.")
2828
String region,
2929
@Schema(description = "예상 모집 인원", example = "4")

src/main/java/com/somemore/recruitboard/dto/request/RecruitBoardUpdateRequestDto.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ public record RecruitBoardUpdateRequestDto(
1919
@Schema(description = "봉사 모집글 내용", example = "서울 청계천 주변 환경 미화 봉사 모집합니다. <br>")
2020
@NotBlank(message = "모집글 내용은 필수 값입니다.")
2121
String content,
22+
@Schema(description = "봉사 지역", example = "서울특별시")
23+
@NotBlank(message = "봉사 지역은 필수 값입니다.")
24+
String region,
2225
@Schema(description = "예상 모집 인원", example = "4")
2326
@NotNull(message = "예상 모집 인원은 필수 값입니다.")
2427
Integer recruitmentCount,
25-
@Schema(description = "봉사 시작 일시", example = "2024-11-20T10:00:00", type = "string")
28+
@Schema(description = "봉사 시작 일시", example = "2024-12-20T10:00:00", type = "string")
2629
@NotNull(message = "봉사 시작 일시는 필수 값입니다.")
2730
@Future(message = "봉사 시작 일시는 내일부터 가능합니다.")
2831
LocalDateTime volunteerStartDateTime,
29-
@Schema(description = "봉사 종료 일시", example = "2024-11-20T12:00:00", type = "string")
32+
@Schema(description = "봉사 종료 일시", example = "2024-12-20T12:00:00", type = "string")
3033
@NotNull(message = "봉사 종료 일시는 필수 값입니다.")
3134
@Future(message = "봉사 종료 일시는 내일부터 가능합니다.")LocalDateTime volunteerEndDateTime,
3235
@Schema(description = "봉사 활동 유형", example = "ENVIRONMENTAL_PROTECTION")

src/test/java/com/somemore/recruitboard/controller/RecruitBoardCommandApiControllerTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ void updateRecruitBoard() throws Exception {
135135
RecruitBoardUpdateRequestDto requestDto = RecruitBoardUpdateRequestDto.builder()
136136
.title("서울 청계천 환경 미화 봉사 모집")
137137
.content("서울 청계천 주변 환경 미화 봉사 모집합니다. <br>")
138+
.region("서울 특별시")
138139
.recruitmentCount(10)
139140
.volunteerStartDateTime(startDateTime)
140141
.volunteerEndDateTime(endDateTime)

src/test/java/com/somemore/recruitboard/domain/RecruitmentInfoTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,15 @@ void updateRecruitmentInfo() {
5555
// given
5656
RecruitmentInfo recruitmentInfo = createRecruitmentInfo();
5757

58+
String region = "서울특별시";
5859
Integer count = 2;
5960
VolunteerCategory volunteerCategory = SAFETY_PREVENTION;
6061
LocalDateTime startDateTime = createUpdateStartDateTime();
6162
LocalDateTime endDateTime = startDateTime.plusHours(2);
6263
Boolean admitted = false;
6364

6465
// when
65-
recruitmentInfo.updateWith(count, volunteerCategory, startDateTime,
66+
recruitmentInfo.updateWith(region, count, volunteerCategory, startDateTime,
6667
endDateTime, admitted);
6768

6869
// then
@@ -99,7 +100,7 @@ void updateRecruitBoardWithInValidVolunteerTime(long minutesOffset) {
99100

100101
// when & then
101102
assertThatThrownBy(
102-
() -> recruitmentInfo.updateWith(3, ADMINISTRATIVE_SUPPORT, startDateTime, endDateTime,
103+
() -> recruitmentInfo.updateWith("",3, ADMINISTRATIVE_SUPPORT, startDateTime, endDateTime,
103104
false)
104105
).isInstanceOf(IllegalArgumentException.class);
105106

src/test/java/com/somemore/recruitboard/service/command/UpdateRecruitBoardServiceTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,15 @@ void updateRecruitBoard() {
6868
LocalDateTime newEndDateTime = newStartDateTime.plusHours(3);
6969
String newImgUrl = "https://image.domain.com/updates";
7070
RecruitBoardUpdateRequestDto dto = RecruitBoardUpdateRequestDto.builder()
71-
.title("업데이트 제목")
72-
.content("업데이트 내용")
73-
.recruitmentCount(1111)
74-
.volunteerStartDateTime(newStartDateTime)
75-
.volunteerEndDateTime(newEndDateTime)
76-
.volunteerCategory(ADMINISTRATIVE_SUPPORT)
77-
.admitted(false)
78-
.build();
71+
.title("업데이트 제목")
72+
.content("업데이트 내용")
73+
.recruitmentCount(1111)
74+
.region("서울특별시")
75+
.volunteerStartDateTime(newStartDateTime)
76+
.volunteerEndDateTime(newEndDateTime)
77+
.volunteerCategory(ADMINISTRATIVE_SUPPORT)
78+
.admitted(false)
79+
.build();
7980

8081
// when
8182
updateRecruitBoardService.updateRecruitBoard(dto, recruitBoard.getId(), centerId,

0 commit comments

Comments
 (0)