Skip to content

Commit

Permalink
Merge pull request #138 from beyond-sw-camp/feature/reservation/tempo…
Browse files Browse the repository at this point in the history
…rary

[Feat] 임의 발행 티켓 조회 #137
  • Loading branch information
yunseul-dev authored Aug 7, 2024
2 parents 316a09d + 5f98289 commit d393d13
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.gamja.tiggle.common.annotation.WebAdapter;
import com.gamja.tiggle.reservation.adapter.in.web.response.ReadMyReservationResponse;
import com.gamja.tiggle.reservation.adapter.in.web.response.ReadReservationResponse;
import com.gamja.tiggle.reservation.adapter.in.web.response.ReadTemporaryReservationResponse;
import com.gamja.tiggle.reservation.application.port.in.ReadReservationCommand;
import com.gamja.tiggle.reservation.application.port.in.ReadReservationUseCase;
import com.gamja.tiggle.reservation.domain.Reservation;
Expand Down Expand Up @@ -63,6 +64,37 @@ public BaseResponse<ReadReservationResponse> readReservation(@RequestParam Long
}
}


@GetMapping("/temporary")
public BaseResponse<ReadTemporaryReservationResponse> readTemporary(@RequestParam Long reservationId) {
try {

ReadReservationCommand command = ReadReservationCommand.builder()
.reservationId(reservationId)
.build();

Reservation reservation = readReservationUseCase.readTemporaryReservation(command);

ReadTemporaryReservationResponse response = new ReadTemporaryReservationResponse(
reservation.getTicketNumber(),
reservation.getDate(),
reservation.getLocationName(),
reservation.getSeatInfo(),
reservation.getTotalPrice(),
reservation.getGradeName(),
reservation.getProgramName(),
reservation.getProgramInfo(),
reservation.getMyPoint()
);

return new BaseResponse<>(BaseResponseStatus.SUCCESS, response);
} catch (BaseException e) {

return new BaseResponse<>(BaseResponseStatus.FAIL, null);
}
}


@GetMapping("/myRead")
public BaseResponse<List<ReadMyReservationResponse>> myRead(@AuthenticationPrincipal CustomUserDetails customUserDetails,
@RequestParam Integer page,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.gamja.tiggle.reservation.adapter.in.web.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ReadTemporaryReservationResponse {
private String ticketNumber; // 예약 번호
private LocalDateTime date; // 공연 날짜
private String locationName; // 공연장
private String seatInfo; // 좌석 정보 : A구역 1층 3열 N번
private Integer ticketPrice; // 가격 정보
private String gradeName; // 좌석 등급

private String programName; // 공연 이름
private String programInfo; // 공연 정보
private Integer myPoint; // 포인트 사용
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ public Reservation readReservation(Reservation reservation) throws BaseException
return reservations;
}

@Override
public Reservation readTemporaryReservation(Reservation reservation) {
ReservationEntity result = repository.findReservationWithDetails(reservation.getId());

return Reservation.builder()
.ticketNumber(result.getTicketNumber())
.date(result.getTimesEntity().getDate())
.locationName(result.getProgramEntity().getLocationEntity().getLocationName())
.seatInfo(
result.getSeatEntity().getRow()+"구역 " +result.getSeatEntity().getSectionEntity().getColumnCount()+"열 "+result.getSeatEntity().getSeatNumber()+"번")
.gradeName(result.getSeatEntity().getSectionEntity().getGradeEntity().getGradeName())
.programName(result.getProgramEntity().getProgramName())
.programInfo(result.getProgramEntity().getProgramInfo())
.myPoint(result.getUser().getPoint())
.build();
}

@Override
public List<Reservation> myRead(ReadReservationCommand command) throws BaseException {
int page = command.getPage();
Expand Down Expand Up @@ -95,4 +112,6 @@ public List<Reservation> myRead(ReadReservationCommand command) throws BaseExcep

return reservations;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@

public interface ReadReservationUseCase {
Reservation readReservation(ReadReservationCommand command) throws BaseException;
Reservation readTemporaryReservation(ReadReservationCommand command) throws BaseException;
List<Reservation> myRead(ReadReservationCommand command) throws BaseException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ public interface ReadReservationPort {
ReservationEntity read(Long reservationId) throws BaseException;
Reservation readReservation(Reservation reservation) throws BaseException;
List<Reservation> myRead(ReadReservationCommand command) throws BaseException;
Reservation readTemporaryReservation(Reservation reservation);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ public Reservation readReservation(ReadReservationCommand command) throws BaseEx
return readReservationPort.readReservation(reservation);
}

@Override
public Reservation readTemporaryReservation(ReadReservationCommand command) throws BaseException {
Reservation reservation = Reservation.builder()
.id(command.getReservationId())
.build();
return readReservationPort.readTemporaryReservation(reservation);
}

@Override
public List<Reservation> myRead(ReadReservationCommand command) throws BaseException {
User user = command.getUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class Reservation {
private String payType; // 결제 방식
private Integer ticketPrice; // 티켓 가격
private Integer usePoint; // 포인트 사용
private Integer myPoint; // 내 포인트

private LocalDateTime createdAt; // 예약 날짜
private LocalDateTime date; // 공연 날짜
Expand Down

0 comments on commit d393d13

Please sign in to comment.