-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into common/dev/feat_club_user_add/#1256
- Loading branch information
Showing
29 changed files
with
897 additions
and
105 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
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,5 @@ | ||
FROM amazoncorretto:11 | ||
|
||
COPY cabinet-0.0.1-SNAPSHOT.jar . | ||
|
||
CMD java -jar -Dspring.profiles.active=main cabinet-0.0.1-SNAPSHOT.jar |
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
25 changes: 25 additions & 0 deletions
25
backend/src/main/java/org/ftclub/cabinet/dto/UserBlackholeInfoDto.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,25 @@ | ||
package org.ftclub.cabinet.dto; | ||
|
||
import java.time.LocalDateTime; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
/** | ||
* 유저의 식별자, 이름, 이메일, 블랙홀 날짜를 반환하는 DTO입니다. | ||
*/ | ||
@AllArgsConstructor | ||
@Getter | ||
@ToString | ||
public class UserBlackholeInfoDto { | ||
|
||
private final Long userId; | ||
private final String name; | ||
private final String email; | ||
private final LocalDateTime blackHoledAt; | ||
|
||
public static UserBlackholeInfoDto of(Long userId, String name, String email, | ||
LocalDateTime blackHoledAt) { | ||
return new UserBlackholeInfoDto(userId, name, email, blackHoledAt); | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
...end/src/main/java/org/ftclub/cabinet/statistics/repository/StatisticsOptionalFetcher.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,13 @@ | ||
package org.ftclub.cabinet.statistics.repository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Log4j2 | ||
public class StatisticsOptionalFetcher { | ||
|
||
|
||
} |
109 changes: 58 additions & 51 deletions
109
backend/src/main/java/org/ftclub/cabinet/statistics/service/StatisticsFacadeServiceImpl.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 |
---|---|---|
@@ -1,71 +1,78 @@ | ||
package org.ftclub.cabinet.statistics.service; | ||
|
||
import static org.ftclub.cabinet.utils.ExceptionUtil.throwIfFalse; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
import org.ftclub.cabinet.cabinet.domain.CabinetStatus; | ||
import org.ftclub.cabinet.cabinet.repository.CabinetRepository; | ||
import org.ftclub.cabinet.cabinet.repository.CabinetOptionalFetcher; | ||
import org.ftclub.cabinet.dto.CabinetFloorStatisticsResponseDto; | ||
import org.ftclub.cabinet.dto.LentsStatisticsResponseDto; | ||
import org.ftclub.cabinet.exception.ExceptionStatus; | ||
import org.ftclub.cabinet.exception.ServiceException; | ||
import org.ftclub.cabinet.lent.repository.LentRepository; | ||
import org.ftclub.cabinet.statistics.repository.StatisticsRepository; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Log4j2 | ||
public class StatisticsFacadeServiceImpl implements StatisticsFacadeService { | ||
|
||
private final StatisticsRepository statisticsRepository; | ||
private final CabinetRepository cabinetRepository; | ||
private final LentRepository lentRepository; | ||
private final StatisticsRepository statisticsRepository; | ||
private final CabinetOptionalFetcher cabinetOptionalFetcher; | ||
private final LentRepository lentRepository; | ||
|
||
// TODO: 로직 수정 필요 | ||
// TODO: 로직 수정 필요 | ||
|
||
/** | ||
* @return | ||
*/ | ||
@Override | ||
public List<CabinetFloorStatisticsResponseDto> getCabinetsCountOnAllFloors() { | ||
log.info("Called getCabinetsCountOnAllFloors"); | ||
List<CabinetFloorStatisticsResponseDto> cabinetFloorStatisticsResponseDtos = new ArrayList<>(); | ||
List<Integer> floors = cabinetRepository.findAllFloorsByBuilding("새롬관"); | ||
for (Integer floor : floors) { | ||
Integer used = statisticsRepository.getCabinetsCountByStatus(floor, CabinetStatus.FULL); | ||
List<Long> availableCabinetsId = statisticsRepository.getAvailableCabinetsId(floor); | ||
Integer unused = 0; | ||
for (Long cabinetId : availableCabinetsId) { | ||
if (lentRepository.countCabinetActiveLent(cabinetId) > 0) { | ||
used++; | ||
} else { | ||
unused++; | ||
} | ||
} | ||
Integer overdue = statisticsRepository.getCabinetsCountByStatus(floor, | ||
CabinetStatus.OVERDUE); | ||
Integer disabled = statisticsRepository.getCabinetsCountByStatus(floor, | ||
CabinetStatus.BROKEN); | ||
Integer total = used + overdue + unused + disabled; | ||
cabinetFloorStatisticsResponseDtos.add( | ||
new CabinetFloorStatisticsResponseDto(floor, total, used, overdue, unused, | ||
disabled)); | ||
} | ||
return cabinetFloorStatisticsResponseDtos; | ||
} | ||
/** | ||
* @return | ||
*/ | ||
@Override | ||
public List<CabinetFloorStatisticsResponseDto> getCabinetsCountOnAllFloors() { | ||
log.info("Called getCabinetsCountOnAllFloors"); | ||
List<CabinetFloorStatisticsResponseDto> cabinetFloorStatisticsResponseDtos = new ArrayList<>(); | ||
List<Integer> floors = cabinetOptionalFetcher.findAllFloorsByBuilding("새롬관"); | ||
throwIfFalse(floors != null, new ServiceException(ExceptionStatus.INVALID_ARGUMENT)); | ||
for (Integer floor : floors) { | ||
Integer used = statisticsRepository.getCabinetsCountByStatus(floor, CabinetStatus.FULL); | ||
List<Long> availableCabinetsId = statisticsRepository.getAvailableCabinetsId(floor); | ||
Integer unused = 0; | ||
for (Long cabinetId : availableCabinetsId) { | ||
if (lentRepository.countCabinetActiveLent(cabinetId) > 0) { | ||
used++; | ||
} else { | ||
unused++; | ||
} | ||
} | ||
Integer overdue = statisticsRepository.getCabinetsCountByStatus(floor, | ||
CabinetStatus.OVERDUE); | ||
Integer disabled = statisticsRepository.getCabinetsCountByStatus(floor, | ||
CabinetStatus.BROKEN); | ||
Integer total = used + overdue + unused + disabled; | ||
cabinetFloorStatisticsResponseDtos.add( | ||
new CabinetFloorStatisticsResponseDto(floor, total, used, overdue, unused, | ||
disabled)); | ||
} | ||
return cabinetFloorStatisticsResponseDtos; | ||
} | ||
|
||
/** | ||
* @param startDate | ||
* @param endDate | ||
* @return | ||
*/ | ||
@Override | ||
public LentsStatisticsResponseDto getCountOnLentAndReturn(LocalDateTime startDate, LocalDateTime endDate) { | ||
log.info("Called getCountOnLentAndReturn"); | ||
Integer lentStartCount = lentRepository.countLentByTimeDuration(startDate, endDate); | ||
Integer lentEndCount = lentRepository.countReturnByTimeDuration(startDate, endDate); | ||
return new LentsStatisticsResponseDto(startDate, endDate, lentStartCount, lentEndCount); | ||
} | ||
/** | ||
* @param startDate | ||
* @param endDate | ||
* @return | ||
*/ | ||
@Override | ||
public LentsStatisticsResponseDto getCountOnLentAndReturn(LocalDateTime startDate, | ||
LocalDateTime endDate) { | ||
log.info("Called getCountOnLentAndReturn"); | ||
throwIfFalse(startDate.isBefore(endDate), | ||
new ServiceException(ExceptionStatus.INVALID_ARGUMENT)); | ||
Integer lentStartCount = lentRepository.countLentByTimeDuration(startDate, endDate); | ||
Integer lentEndCount = lentRepository.countReturnByTimeDuration(startDate, endDate); | ||
return new LentsStatisticsResponseDto(startDate, endDate, lentStartCount, lentEndCount); | ||
} | ||
} |
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
Oops, something went wrong.