Skip to content

Commit

Permalink
Refactor: 예약 목록 조회시 관리자 조회 차별화 (#298)
Browse files Browse the repository at this point in the history
* Refactor: getGroupReservation 메소드 수정

* Chore: 도커 빌드 명령 수정
  • Loading branch information
gitseoyeon authored Nov 7, 2024
1 parent 8302df6 commit 7c7dd26
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
run: test -f ./src/main/resources/application.properties && echo "File exists" || echo "File does not exist"

- name: docker image build
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/openbook:latest .
run: docker build --build-arg DEPENDENCY=build/dependency -t ${{ secrets.DOCKER_USERNAME }}/openbook --platform linux/amd64 .

- name: docker login
uses: docker/login-action@v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public List<BoothReservationDto> getReservationsByBooth(long boothId){
if(!booth.getStatus().equals(BoothStatus.APPROVE)){
throw new OpenBookException(ErrorCode.BOOTH_NOT_APPROVED);
}
return getGroupReservation(boothId);
return getGroupReservation(boothId, false);
}

@Transactional
Expand All @@ -66,10 +66,10 @@ public List<BoothReservationDto> getAllManageReservations(Long userId, Long boot
if(!booth.getManager().getId().equals(userId)){
throw new OpenBookException(ErrorCode.FORBIDDEN_ACCESS);
}
return getGroupReservation(boothId);
return getGroupReservation(boothId, true);
}

private List<BoothReservationDto> getGroupReservation(Long boothId){
private List<BoothReservationDto> getGroupReservation(Long boothId, boolean isAdmin) {
List<BoothReservation> reservations = getBoothReservations(boothId);
Map<String, List<BoothReservation>> groupedByName = reservations.stream()
.collect(Collectors.groupingBy(BoothReservation::getName));
Expand All @@ -85,6 +85,18 @@ private List<BoothReservationDto> getGroupReservation(Long boothId){
List<BoothReservationDetailDto> details = dateEntry.getValue().stream()
.flatMap(reservation -> reservationDetailService
.getReservationDetails(reservation.getId()).stream())
.map(detail -> {
if (isAdmin) {
return detail;
} else {
return new BoothReservationDetailDto(
detail.id(),
detail.times(),
detail.status(),
null
);
}
})
.collect(Collectors.toList());

return BoothReservationDateDto.of(date, details);
Expand Down

0 comments on commit 7c7dd26

Please sign in to comment.