-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
142 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/umc/kkijuk/server/recruit/controller/response/RecruitByEndDate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package umc.kkijuk.server.recruit.controller.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import umc.kkijuk.server.recruit.domain.Recruit; | ||
|
||
import java.time.LocalDate; | ||
import java.util.*; | ||
|
||
@Getter | ||
@Builder | ||
public class RecruitByEndDate { | ||
private final LocalDate endDate; | ||
private int count; | ||
private List<RecruitListResponse> recruits; | ||
|
||
public static List<RecruitByEndDate> from(List<Recruit> recruits) { | ||
List<RecruitByEndDate> outputs = new ArrayList<>(); | ||
recruits.forEach(recruit -> { | ||
Optional<RecruitByEndDate> o = outputs.stream() | ||
.filter(item -> recruit.getEndTime().toLocalDate().isEqual(item.getEndDate())) | ||
.findFirst(); | ||
o.ifPresent(recruitByEndDate -> { | ||
recruitByEndDate.recruits.add(RecruitListResponse.from(recruit)); | ||
recruitByEndDate.count++; | ||
}); | ||
if (o.isEmpty()) { | ||
outputs.add(RecruitByEndDate.builder() | ||
.endDate(recruit.getEndTime().toLocalDate()) | ||
.count(1) | ||
.recruits(new ArrayList<>(Arrays.asList(RecruitListResponse.from(recruit)))) | ||
.build()); | ||
} | ||
}); | ||
|
||
outputs.sort(Comparator.comparing(RecruitByEndDate::getEndDate)); | ||
return outputs; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...java/umc/kkijuk/server/recruit/controller/response/RecruitListByEndTimeAfterResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package umc.kkijuk.server.recruit.controller.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import umc.kkijuk.server.recruit.domain.Recruit; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@Builder | ||
public class RecruitListByEndTimeAfterResponse { | ||
private final int totalCount; | ||
private final List<RecruitByEndDate> outputs; | ||
|
||
public static RecruitListByEndTimeAfterResponse from(List<Recruit> recruits) { | ||
return RecruitListByEndTimeAfterResponse.builder() | ||
.totalCount(recruits.size()) | ||
.outputs(RecruitByEndDate.from(recruits)) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters