-
Notifications
You must be signed in to change notification settings - Fork 2
[DDING-88] 동아리 지원 폼지 전체 조회 API 구현 #237
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ddingdong.ddingdongBE.domain.form.controller.dto.response; | ||
|
||
import ddingdong.ddingdongBE.domain.form.service.dto.query.FormListQuery; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.time.LocalDate; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record FormListResponse( | ||
@Schema(description = "지원 폼지 ID", example = "1") | ||
Long formId, | ||
@Schema(description = "지원 폼지 제목", example = "폼지 제목입니다.") | ||
String title, | ||
@Schema(description = "지원 폼지 시작일", example = "2001-01-01") | ||
LocalDate startDate, | ||
@Schema(description = "지원 폼지 종료일", example = "2001-01-02") | ||
LocalDate endData, | ||
@Schema(description = "활성화 여부", example = "true") | ||
boolean isActive | ||
) { | ||
|
||
public static FormListResponse from(FormListQuery query) { | ||
return FormListResponse.builder() | ||
.formId(query.formId()) | ||
.title(query.title()) | ||
.startDate(query.startDate()) | ||
.endData(query.endData()) | ||
.isActive(query.isActive()) | ||
.build(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
package ddingdong.ddingdongBE.domain.form.repository; | ||
|
||
import ddingdong.ddingdongBE.domain.club.entity.Club; | ||
import ddingdong.ddingdongBE.domain.form.entity.Form; | ||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface FormRepository extends JpaRepository<Form, Long> { | ||
|
||
List<Form> findAllByClub(Club club); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package ddingdong.ddingdongBE.domain.form.service.dto.query; | ||
|
||
import ddingdong.ddingdongBE.domain.form.entity.Form; | ||
import java.time.LocalDate; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record FormListQuery( | ||
Long formId, | ||
String title, | ||
LocalDate startDate, | ||
LocalDate endData, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 필드명 오타를 수정해주세요.
다음과 같이 수정해주세요: - LocalDate endData,
+ LocalDate endDate, 이에 따라 팩토리 메서드도 수정이 필요합니다: - .endData(form.getEndDate())
+ .endDate(form.getEndDate())
|
||
boolean isActive | ||
) { | ||
|
||
public static FormListQuery from(Form form, boolean isActive) { | ||
return FormListQuery.builder() | ||
.formId(form.getId()) | ||
.title(form.getTitle()) | ||
.startDate(form.getStartDate()) | ||
.endData(form.getEndDate()) | ||
.isActive(isActive) | ||
.build(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package ddingdong.ddingdongBE.common.utils; | ||
|
||
import java.time.LocalDate; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class TimeUtilsTest { | ||
|
||
@DisplayName("현재 날짜가 기간 내 포함된다면 true를 반환한다.") | ||
@Test | ||
void isDateInRange() { | ||
// given | ||
LocalDate now = LocalDate.now(); | ||
LocalDate startDate = now.minusDays(1); | ||
LocalDate endDate = now.plusDays(1); | ||
// when | ||
boolean isActive = TimeUtils.isDateInRange(now, startDate, endDate); | ||
// then | ||
Assertions.assertThat(isActive).isTrue(); | ||
} | ||
Comment on lines
+10
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 경계값 테스트 케이스 추가가 필요합니다. 현재 구현은 기본적인 케이스만 테스트하고 있습니다. 다음과 같은 경계값 테스트 케이스를 추가하면 좋을 것 같습니다:
다음과 같이 테스트 메소드를 추가해보세요: @DisplayName("현재 날짜가 시작일과 같다면 true를 반환한다.")
@Test
void isDateInRange_WhenCurrentDateEqualsStartDate() {
// given
LocalDate now = LocalDate.now();
// when
boolean isActive = TimeUtils.isDateInRange(now, now, now.plusDays(1));
// then
Assertions.assertThat(isActive).isTrue();
}
@DisplayName("현재 날짜가 종료일과 같다면 true를 반환한다.")
@Test
void isDateInRange_WhenCurrentDateEqualsEndDate() {
// given
LocalDate now = LocalDate.now();
// when
boolean isActive = TimeUtils.isDateInRange(now, now.minusDays(1), now);
// then
Assertions.assertThat(isActive).isTrue();
}
@DisplayName("시작일이 null이면 false를 반환한다.")
@Test
void isDateInRange_WhenStartDateIsNull() {
// given
LocalDate now = LocalDate.now();
// when
boolean isActive = TimeUtils.isDateInRange(now, null, now.plusDays(1));
// then
Assertions.assertThat(isActive).isFalse();
}
@DisplayName("종료일이 null이면 false를 반환한다.")
@Test
void isDateInRange_WhenEndDateIsNull() {
// given
LocalDate now = LocalDate.now();
// when
boolean isActive = TimeUtils.isDateInRange(now, now.minusDays(1), null);
// then
Assertions.assertThat(isActive).isFalse();
}
@DisplayName("현재 날짜가 범위를 벗어나면 false를 반환한다.")
@Test
void isDateInRange_WhenCurrentDateIsOutOfRange() {
// given
LocalDate now = LocalDate.now();
LocalDate startDate = now.plusDays(1);
LocalDate endDate = now.plusDays(2);
// when
boolean isActive = TimeUtils.isDateInRange(now, startDate, endDate);
// then
Assertions.assertThat(isActive).isFalse();
} |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
필드명 오타를 수정해주세요.
endData
는endDate
의 오타로 보입니다. 일관성을 위해 수정이 필요합니다.다음과 같이 수정해주세요:
그리고 from 메서드에서도:
Also applies to: 27-27