Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] 명세서랑 다른 점 수정 및 로직 변경 #13

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.third.thirdseminar.controller.dto.response;
import org.third.thirdseminar.domain.TimeRange;

public record AirResultDto(DateDto dateDto, Long airId, String airName, TimeRange startTime, TimeRange endTime) {
public static AirResultDto of(DateDto dateDto, Long airId, String airName, TimeRange startTime, TimeRange endTime) {
public record AirResultDto(DateDto dateDto, Long airId, String airName, TimeRangeDto startTime, TimeRangeDto endTime) {
public static AirResultDto of(DateDto dateDto, Long airId, String airName, TimeRangeDto startTime, TimeRangeDto endTime) {
return new AirResultDto(dateDto, airId, airName, startTime, endTime);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public class MainService {

public List<CardDto> getCards(){
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd E");
NumberFormat priceFormat = NumberFormat.getCurrencyInstance();
priceFormat.setCurrency(Currency.getInstance("KRW"));
NumberFormat priceFormat = NumberFormat.getInstance(Locale.getDefault());

return reservationJpaRepository.findAllExcludingCity("삿포로").stream().map((reservation)->
CardDto.of(reservation.getCityName(),
reservation.getCountry(),
format.format(reservation.getStartDate()),
format.format(reservation.getEndDate()),
reservation.getAir().getAirName(),
priceFormat.format(providerMinPrice(reservation.getTickets()))+"원")
priceFormat.format(providerMinPrice(reservation.getTickets()))+"원 출발")
).collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private TimeRangeDto TimeRangeFormat(TimeRange timeRange){
String endTime = timeRange.getEnd().format( DateTimeFormatter.ofPattern( "H:mm" ));
String during = timeRange.getDuring().format(DateTimeFormatter.ofPattern("H시간 mm분"));


return new TimeRangeDto(startTime, endTime, during);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
package org.third.thirdseminar.service;

import java.text.DecimalFormat;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.stream.Collectors;

import org.springframework.stereotype.Service;
import org.third.thirdseminar.controller.dto.request.TicketRequestDto;
import org.third.thirdseminar.controller.dto.response.DateDto;
import org.third.thirdseminar.controller.dto.response.TicketDto;
import org.third.thirdseminar.controller.dto.response.TimeRangeDto;
import org.third.thirdseminar.domain.Air;
import org.third.thirdseminar.controller.dto.response.AirResultDto;
import org.third.thirdseminar.domain.Reservation;
import org.third.thirdseminar.domain.TimeRange;
import org.third.thirdseminar.exception.Error;
import org.third.thirdseminar.exception.model.NotFoundException;
import org.third.thirdseminar.infrastructure.AirJpaRepository;
import org.third.thirdseminar.infrastructure.ReservationJpaRepository;
import org.third.thirdseminar.infrastructure.TicketJpaRepository;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
@RequiredArgsConstructor
public class TicketService {
private final ReservationJpaRepository reservationJpaRepository;
private final AirJpaRepository airJpaRepository;
private final TicketJpaRepository ticketJpaRepository;
private final DecimalFormat df = new DecimalFormat("###,###");


public List<TicketDto> getTicketList(){
return ticketJpaRepository.findAll().stream().map(
(ticket)->
Expand All @@ -49,11 +53,20 @@ public AirResultDto getAirInformation(TicketRequestDto ticketRequestDto){
dateDto,
air.getAirId(),
air.getAirName(),
reservation.getStartTime(),
reservation.getEndTime()
TimeRangeFormat(reservation.getStartTime()),
TimeRangeFormat(reservation.getEndTime())
);
}

private TimeRangeDto TimeRangeFormat(TimeRange timeRange){
String startTime = timeRange.getStart().format( DateTimeFormatter.ofPattern( "HH:mm" ));
String endTime = timeRange.getEnd().format( DateTimeFormatter.ofPattern( "HH:mm" ));
String during = timeRange.getDuring().format(DateTimeFormatter.ofPattern("H시간 mm분"));


return new TimeRangeDto(startTime, endTime, during);
}




Expand Down