Skip to content
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 @@ -58,7 +58,7 @@ public static class CareerOverviewDto {

@NotNull
@JsonProperty("left_days")
private final String leftDays;
private final int leftDays;

@NotNull
@JsonProperty("status")
Expand All @@ -84,7 +84,7 @@ public CareerOverviewDto(
List<EVisa> visa,
String hostName,
String organizerName,
String leftDays,
int leftDays,
ERecruitmentStatus status,
String recruitmentStartDate,
String recruitmentEndDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static class CareerOverviewDto {

@NotNull
@JsonProperty("left_days")
private final String leftDays;
private final int leftDays;

@NotNull
@JsonProperty("status")
Expand All @@ -88,7 +88,7 @@ public CareerOverviewDto(
List<EVisa> visa,
String hostName,
String organizerName,
String leftDays,
int leftDays,
ERecruitmentStatus status,
String recruitmentStartDate,
String recruitmentEndDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public class ReadGuestCareersOverviewsService implements ReadGuestCareersOvervie
// 최신순
private static final String RECENT = "RECENT";

private static final String END = "end";

private final CareerRepository careerRepository;

@Override
Expand Down Expand Up @@ -87,19 +85,19 @@ private ReadGuestsCareersOverviewsResponseDto.CareerOverviewDto toDto(Career car
.build();
}

private String calculateLeftDays(LocalDate startDate, LocalDate endDate) {
private int calculateLeftDays(LocalDate startDate, LocalDate endDate) {
LocalDate today = LocalDate.now();
Long days;

if (today.isBefore(startDate)) {
days = ChronoUnit.DAYS.between(LocalDate.now(), startDate);
}
else if (today.isEqual(startDate) || today.isAfter(startDate)) {
days = ChronoUnit.DAYS.between(LocalDate.now(), endDate);
}
else {
days = null;
// 아직 시작 전 → 시작일까지 남은 날짜
return (int) ChronoUnit.DAYS.between(today, startDate);
} else if (!today.isAfter(endDate)) {
// 시작일 이상이고 종료일 이하 → 종료일까지 남은 날짜
return (int) ChronoUnit.DAYS.between(today, endDate);
} else {
// 종료일 이후 → 이미 지난 기간 (음수로 반환)
return (int) ChronoUnit.DAYS.between(endDate, today) * -1;
}
return days != null ? days + " days left" : END;
}

private ERecruitmentStatus calculateRecruitmentStatus(LocalDate start, LocalDate end) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public class ReadUserCareersOverviewsService implements ReadUsersCareersOverview
// 최신순
private static final String RECENT = "RECENT";

private static final String END = "end";

private final CareerRepository careerRepository;
private final BookMarkCareerRepository bookMarkCareerRepository;

Expand Down Expand Up @@ -128,17 +126,19 @@ private ReadUsersCareersOverviewsResponseDto.CareerOverviewDto toDto(Career care
.build();
}

private String calculateLeftDays(LocalDate startDate, LocalDate endDate) {
private int calculateLeftDays(LocalDate startDate, LocalDate endDate) {
LocalDate today = LocalDate.now();
Long days;

if (today.isBefore(startDate)) {
days = ChronoUnit.DAYS.between(LocalDate.now(), startDate);
} else if (today.isEqual(startDate) || today.isAfter(startDate)) {
days = ChronoUnit.DAYS.between(LocalDate.now(), endDate);
// 아직 시작 전 → 시작일까지 남은 날짜
return (int) ChronoUnit.DAYS.between(today, startDate);
} else if (!today.isAfter(endDate)) {
// 시작일 이상이고 종료일 이하 → 종료일까지 남은 날짜
return (int) ChronoUnit.DAYS.between(today, endDate);
} else {
days = null;
// 종료일 이후 → 이미 지난 기간 (음수로 반환)
return (int) ChronoUnit.DAYS.between(endDate, today) * -1;
}
return days != null ? days + " days left" : END;
}

private ERecruitmentStatus calculateRecruitmentStatus(LocalDate start, LocalDate end) {
Expand Down