-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from Kusitms-28th-Kukathon-F/feat/16-tumbler-h…
…istory Feat/16 tumbler history
- Loading branch information
Showing
5 changed files
with
92 additions
and
2 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
36 changes: 36 additions & 0 deletions
36
src/main/java/kusitms/server/domain/tumbler/history/dto/response/HistoryRankResponseDto.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,36 @@ | ||
package kusitms.server.domain.tumbler.history.dto.response; | ||
|
||
import kusitms.server.domain.department.entity.Department; | ||
import kusitms.server.domain.tumbler.history.entity.TumblerHistory; | ||
import kusitms.server.domain.tumbler.history.util.ListComparatorQuarter; | ||
import kusitms.server.domain.tumbler.history.util.ListComparatorTumblerHistory; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
@Builder | ||
@Getter | ||
public class HistoryRankResponseDto { | ||
|
||
private Integer rank; | ||
|
||
private Integer tumblerCount; | ||
|
||
|
||
public static HistoryRankResponseDto of(List<TumblerHistory> tumblerHistories, String deptName) { | ||
tumblerHistories.sort(new ListComparatorTumblerHistory()); | ||
Integer rank = 0; | ||
|
||
for (int i = 0; i < tumblerHistories.size(); i++) { | ||
if(deptName.equals(tumblerHistories.get(i).getDepartment().getDeptName())) { | ||
rank = i; | ||
} | ||
} | ||
|
||
return HistoryRankResponseDto.builder() | ||
.rank(rank + 1) | ||
.tumblerCount(tumblerHistories.get(rank).getTumblerCount()) | ||
.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
21 changes: 21 additions & 0 deletions
21
src/main/java/kusitms/server/domain/tumbler/history/util/ListComparatorTumblerHistory.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 kusitms.server.domain.tumbler.history.util; | ||
|
||
import kusitms.server.domain.tumbler.history.dto.response.HistoryQuarterDetailResponseDto; | ||
import kusitms.server.domain.tumbler.history.entity.TumblerHistory; | ||
|
||
import java.util.Comparator; | ||
|
||
public class ListComparatorTumblerHistory implements Comparator<TumblerHistory> { | ||
|
||
@Override | ||
public int compare(TumblerHistory o1, TumblerHistory o2) { | ||
|
||
if(o1.getTumblerCount() > o2.getTumblerCount()){ | ||
return -1; | ||
}else if(o1.getTumblerCount() < o2.getTumblerCount()){ | ||
return 1; | ||
}else{ | ||
return 0; | ||
} | ||
} | ||
} |