Skip to content

Commit

Permalink
Merge branch 'develop' into feature/my-page/headinfo
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/com/gamja/tiggle/reservation/adapter/out/persistence/ReadReservationPersistenceAdapter.java
#	src/main/java/com/gamja/tiggle/reservation/application/port/out/ReadReservationPort.java
  • Loading branch information
ashd89 committed Aug 8, 2024
2 parents 7d83e3c + acd2c3e commit 3c15853
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ out/
### VS Code ###
.vscode/

appplication.yml
appplication-local.yml
/gradle/wrapper/gradle-wrapper.jar
/gradle/wrapper/gradle-wrapper.properties
/gradlew
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,15 @@ public List<Program> readRealTimeAll(LocalDateTime currentDateTime) throws BaseE
public List<Program> readRealTimeAllPaged(ReadProgramCommand command) throws BaseException {
int page = command.getPage();
int size = command.getSize();
LocalDateTime currentDateTime = LocalDateTime.now();
// 현재 시간을 기준으로 예매 끝난 공연은 나오지 않게 하는 filter
// LocalDateTime currentDateTime = LocalDateTime.now();

Pageable pageable = PageRequest.of(page, size);
Page<ProgramEntity> programEntityPage = jpaProgramRepository.findAll(pageable);

List<Program> programs = programEntityPage.stream()
.filter(p -> p.getReservationOpenDate().isAfter(currentDateTime))
.sorted(Comparator.comparing(ProgramEntity::getReservationOpenDate)) // 예약 오픈 날짜 기준 정렬
// .filter(p -> p.getReservationOpenDate().isAfter(currentDateTime))
.sorted(Comparator.comparing(ProgramEntity::getProgramEndDate)) // 예약 오픈 날짜 기준 정렬
.map(p -> Program.builder()
.id(p.getId())
.categoryId(p.getCategoryEntity().getId())
Expand Down
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
Expand Up @@ -2,9 +2,9 @@

import com.gamja.tiggle.common.BaseException;
import com.gamja.tiggle.common.BaseResponse;
import com.gamja.tiggle.common.BaseResponseStatus;
import com.gamja.tiggle.common.annotation.WebAdapter;
import com.gamja.tiggle.reservation.adapter.in.web.request.VerifySeatRequest;
import com.gamja.tiggle.reservation.adapter.in.web.response.VerifySeatResponse;
import com.gamja.tiggle.reservation.application.port.in.VerifySeatCommand;
import com.gamja.tiggle.reservation.application.port.in.VerifySeatUseCase;
import com.gamja.tiggle.user.domain.CustomUserDetails;
Expand All @@ -25,14 +25,14 @@ public class VerifySeatController {

@PostMapping
@Operation(summary = "좌석 예약 검증", description = "선택한 좌석이 예약 가능한지 검증하는 API 입니다.")
public BaseResponse<Void> verifySeatController(
public BaseResponse<VerifySeatResponse> verifySeatController(
@RequestBody @Valid VerifySeatRequest request,
@AuthenticationPrincipal CustomUserDetails customUserDetails) {

VerifySeatCommand command = from(request,customUserDetails.getUser().getId());
try {
verifySeatUseCase.verifySeat(command);
return new BaseResponse<>(BaseResponseStatus.SUCCESS);
VerifySeatResponse response = verifySeatUseCase.verifySeat(command);
return new BaseResponse<>(response);
} catch (BaseException e) {
return new BaseResponse<>(e.getStatus());
}
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 @@ -8,6 +8,5 @@
@Getter
@Builder
public class VerifySeatResponse {

private List<Long> seatId;
private Long reservationId;
}
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 = reservationRepository.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 @@ -100,4 +117,6 @@ public List<Reservation> myRead(ReadReservationCommand command) throws BaseExcep
public Long getReservationCnt(Long userid) throws BaseException {
return reservationRepository.countReservationsByUserId(userid);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ public class SaveReservationAdapter implements SaveReservationPort {
private final ReservationRepository reservationRepository;

@Override
public void save(Reservation reservation) {

public Long save(Reservation reservation) {
ReservationEntity reservationEntity = from(reservation);
reservationRepository.save(reservationEntity);
ReservationEntity savedEntity = reservationRepository.save(reservationEntity);

return savedEntity.getId();
}


private static ReservationEntity from(Reservation reservation) {
return ReservationEntity.builder()
.programEntity(new ProgramEntity(reservation.getProgramId()))
Expand Down
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
@@ -1,10 +1,11 @@
package com.gamja.tiggle.reservation.application.port.in;

import com.gamja.tiggle.common.BaseException;
import com.gamja.tiggle.reservation.adapter.in.web.response.VerifySeatResponse;

import java.util.List;

public interface VerifySeatUseCase {

void verifySeat(VerifySeatCommand command) throws BaseException;
VerifySeatResponse verifySeat(VerifySeatCommand command) throws BaseException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public interface ReadReservationPort {
Reservation readReservation(Reservation reservation) throws BaseException;
List<Reservation> myRead(ReadReservationCommand command) throws BaseException;
Long getReservationCnt(Long userid) throws BaseException;
Reservation readTemporaryReservation(Reservation reservation);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

public interface SaveReservationPort {

void save(Reservation reservation);
Long save(Reservation reservation);
void update(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 @@ -2,14 +2,14 @@

import com.gamja.tiggle.common.BaseException;
import com.gamja.tiggle.common.annotation.UseCase;
import com.gamja.tiggle.reservation.adapter.in.web.response.VerifySeatResponse;
import com.gamja.tiggle.reservation.application.port.in.VerifySeatCommand;
import com.gamja.tiggle.reservation.application.port.in.VerifySeatUseCase;
import com.gamja.tiggle.reservation.application.port.out.SaveReservationPort;
import com.gamja.tiggle.reservation.application.port.out.VerifySeatPort;
import com.gamja.tiggle.reservation.domain.Reservation;
import com.gamja.tiggle.reservation.domain.Seat;
import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
Expand All @@ -23,7 +23,7 @@ public class VerifySeatService implements VerifySeatUseCase {
private final SaveReservationPort saveReservationPort;

@Override
public void verifySeat(VerifySeatCommand command) throws BaseException {
public VerifySeatResponse verifySeat(VerifySeatCommand command) throws BaseException {

//좌석 검증
Seat seat = Seat.builder().id(command.getSeatId()).build();
Expand All @@ -33,8 +33,9 @@ public void verifySeat(VerifySeatCommand command) throws BaseException {
//검증했으면 예약 임시 저장
String ticketNumber = getTicketNumber();
Reservation reservation = from(command, ticketNumber);
saveReservationPort.save(reservation);
Long id = saveReservationPort.save(reservation);

return VerifySeatResponse.builder().reservationId(id).build();
}

private static String getTicketNumber() {
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
35 changes: 15 additions & 20 deletions src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,21 @@ INSERT INTO tiggle.category (category_name) VALUES
-- program 테이블
INSERT INTO tiggle.program (id, age, program_end_date, program_info, program_name, program_start_date,
reservation_open_date, runtime, category_id, location_id) VALUES
(null, 14, '2024-09-29', '뮤지컬 〈시카고〉', '시카고', '2024-08-25',
'2024-08-18 20:00:00', 145, 1, 1),
(null, 12, '2024-10-31', '뮤지컬 〈레 미제라블〉', '레 미제라블', '2024-08-24',
'2024-08-17 20:00:00', 160, 1, 2),
(null, 8, '2024-12-15', '뮤지컬 〈라이온 킹〉', '라이온 킹', '2024-08-26',
'2024-08-19 20:00:00', 135, 1, 3),
(null, 10, '2024-11-20', '뮤지컬 〈위키드〉', '위키드', '2024-08-27',
'2024-08-20 20:00:00', 150, 1, 4),
(null, 7, '2024-08-30', '뮤지컬 〈캣츠〉', '캣츠', '2024-08-28',
'2024-08-21 20:00:00', 130, 1, 5),
(null, 15, '2024-09-30', '공연 〈베토벤 교향곡〉', '베토벤 교향곡', '2024-08-29',
'2024-08-22 20:00:00', 120, 2, 1),
(null, 16, '2024-11-10', '공연 〈모차르트 레퀴엠〉', '모차르트 레퀴엠', '2024-08-30',
'2024-08-23 20:00:00', 90, 2, 2),
(null, 18, '2024-10-25', '공연 〈바흐 무반주 첼로 모음곡〉', '바흐 무반주 첼로 모음곡', '2024-09-01',
'2024-08-25 20:00:00', 105, 2, 3),
(null, 13, '2024-12-05', '공연 〈쇼팽 피아노 협주곡〉', '쇼팽 피아노 협주곡', '2024-09-02',
'2024-08-26 20:00:00', 110, 2, 4),
(null, 12, '2024-08-15', '공연 〈비발디 사계〉', '비발디 사계', '2024-09-03',
'2024-08-27 20:00:00', 100, 2, 5);
(null, 19, '2024-07-30', '<시카고>는 여전히 최면을 걸 듯 반짝인다', '<뮤지컬> 시카고', '2024-07-01', '2024-06-28 20:00:00', 145, 1, 2),
(null, 12, '2024-09-30', '눈과 귀를 위한 축제, 전세계 흥행 1위', '<뮤지컬> 라이온 킹', '2024-09-02', '2024-08-10 20:00:00', 150, 1, 3),
(null, 12, '2024-09-30', '오즈를 방문하시는 관객들을 위한 가이드', '<뮤지컬> 위키드', '2024-09-03', '2024-08-05 20:00:00', 170, 1, 4),
(null, 12, '2024-09-30', '전 세계가 사랑한 영원한 명작 캣츠', '<뮤지컬> 캣츠', '2024-09-01', '2024-08-04 20:00:00', 130, 1, 5),
(null, 12, '2024-09-07', '놓치면 안 될 올해 최고의 화제작, 가슴 벅찬 감동!', '<뮤지컬> 베토벤 교향곡', '2024-08-01', '2024-07-31 20:00:00', 170, 2, 1),
(null, 12, '2024-08-01', '네 남녀가 만나면서 일어나는 레트로 코믹극', '<연극> 서울 대학로 연극 라면', '2024-07-01', '2024-06-15 20:00:00', 100, 3, 4),
(null, 12, '2024-07-20', '여러분의 어떤날들을 선명하게 해줄 플레이리스트', '<콘서트> 유승우 앨범 발매 기념 콘서트', '2024-07-01', '2024-06-15 20:00:00', 105, 2, 3),
(null, 12, '2024-09-30', 'MONSTA X 7TH OFFICIAL FANCLUB MONBEBE FAN-CONCERT', '<콘서트> 2024 MONSTA X', '2024-09-01', '2024-08-02 20:00:00', 110, 2, 4),
(null, 12, '2024-09-30', '유애나들을 위한 아이유의 공연 ! 전국을 찾아갑니다 !', '<콘서트> 2024 IU H.E.R.WORLD TOUR CONCERT IN SEOUL', '2024-09-01', '2024-08-01 20:00:00', 150, 2, 5),
(null, 14, '2024-09-30', '2025 여름특별공연 연극 새빨간 거짓말', '<연극> 2025 새빨간 거짓말', '2024-09-01', '2024-07-31 20:00:00', 90, 3, 5),
(null, 8, '2024-09-30', '준생俊生:영웅으로 살다.', '<연극> 준생 俊生', '2024-09-01', '2024-07-30 20:00:00', 70, 3, 5),
(null, 14, '2024-10-30', '프랑스 연극의 현재 조엘 폼므라가 그리는 미래', '<연극> 조엘 폼므라 ‘이야기와 전설’', '2024-10-01', '2024-09-15 20:00:00', 110, 3, 5),
(null, 14, '2024-09-30', '피나를 통해 들여다보는 우리의 과거와 현재', '<연극> Creator’s Box:‘P와 함께 춤을’', '2024-09-01', '2024-07-28 20:00:00', 120, 3, 5),
(null, 12, '2024-09-30', '최정윤의 청량하고 맑은 목소리로 함께하는 여름 콘서트!', '<콘서트> 최정윤 단독 콘서트 ‘summer swim’', '2024-09-01', '2024-08-20 20:00:00', 90, 2, 5),
(null, 12, '2024-09-30', '광야로 걸어가는 에스파의 2025년 콘서트! ', '<콘서트> 2025 aespa LIVE TOUR-SYNK:PARALLEL LINE-', '2024-09-01', '2024-07-26 20:00:00', 120, 2, 5);
INSERT INTO tiggle.section (location_id, grade_id, section_name, row_count, column_count) VALUES
(1, 1, 'Square', 5, 5),
(1, 1, 'Rectangle', 5, 5),
Expand Down

0 comments on commit 3c15853

Please sign in to comment.