diff --git a/src/main/java/com/hanaro/triptogether/trip/domain/Trip.java b/src/main/java/com/hanaro/triptogether/trip/domain/Trip.java index 6a1d141..a2e4707 100644 --- a/src/main/java/com/hanaro/triptogether/trip/domain/Trip.java +++ b/src/main/java/com/hanaro/triptogether/trip/domain/Trip.java @@ -37,6 +37,9 @@ public class Trip { @Column(nullable = false, precision = 20, scale = 2) private BigDecimal tripGoalAmount = BigDecimal.ZERO; + @Column(nullable = false, precision = 20, scale = 2) + private BigDecimal tripExpectedAmount = BigDecimal.ZERO; + @Column(nullable = false) private Integer tripDay = 1; @@ -74,6 +77,7 @@ public TripResDto toTrip() { .tripDay(this.getTripDay()) .tripContent(this.getTripContent()) .tripGoalAmount(this.getTripGoalAmount()) + .tripExpectedAmount(this.getTripExpectedAmount()) .tripName(this.getTripName()) .tripStartDay(this.getTripStartDay()) .build(); diff --git a/src/main/java/com/hanaro/triptogether/trip/domain/TripRepository.java b/src/main/java/com/hanaro/triptogether/trip/domain/TripRepository.java index ea2fb31..6820dec 100644 --- a/src/main/java/com/hanaro/triptogether/trip/domain/TripRepository.java +++ b/src/main/java/com/hanaro/triptogether/trip/domain/TripRepository.java @@ -13,6 +13,6 @@ public interface TripRepository extends JpaRepository { List findAllByTeam_TeamIdx(Long teamIdx); @Modifying - @Query("UPDATE Trip t SET t.tripGoalAmount = :goalAmount WHERE t.tripIdx = :tripIdx") - void updateGoalAmount(@Param("tripIdx") Long tripIdx, @Param("goalAmount") BigDecimal goalAmount); + @Query("UPDATE Trip t SET t.tripExpectedAmount = :tripExpectedAmount WHERE t.tripIdx = :tripIdx") + void updateExpectedAmount(@Param("tripIdx") Long tripIdx, @Param("tripExpectedAmount") BigDecimal expectedAmount); } diff --git a/src/main/java/com/hanaro/triptogether/trip/dto/response/TripResDto.java b/src/main/java/com/hanaro/triptogether/trip/dto/response/TripResDto.java index d4be00d..bd9d44d 100644 --- a/src/main/java/com/hanaro/triptogether/trip/dto/response/TripResDto.java +++ b/src/main/java/com/hanaro/triptogether/trip/dto/response/TripResDto.java @@ -18,6 +18,7 @@ public class TripResDto { private String tripName; private String tripContent; private BigDecimal tripGoalAmount; + private BigDecimal tripExpectedAmount; private Integer tripDay; private Integer tripImg; private LocalDate tripStartDay; diff --git a/src/main/java/com/hanaro/triptogether/trip/service/TripService.java b/src/main/java/com/hanaro/triptogether/trip/service/TripService.java index da1352d..41f27f3 100644 --- a/src/main/java/com/hanaro/triptogether/trip/service/TripService.java +++ b/src/main/java/com/hanaro/triptogether/trip/service/TripService.java @@ -143,6 +143,7 @@ private TripResDto toTripResDto(Trip trip) { .tripDay(trip.getTripDay()) .tripContent(trip.getTripContent()) .tripGoalAmount(trip.getTripGoalAmount()) + .tripExpectedAmount(trip.getTripExpectedAmount()) .tripName(trip.getTripName()) .tripStartDay(trip.getTripStartDay()) .build(); @@ -156,6 +157,7 @@ private TripResDto toTripResDto(Trip trip) { .tripDay(trip.getTripDay()) .tripContent(trip.getTripContent()) .tripGoalAmount(trip.getTripGoalAmount()) + .tripExpectedAmount(trip.getTripExpectedAmount()) .tripName(trip.getTripName()) .tripStartDay(trip.getTripStartDay()) .countryIdx(country.getCountryIdx()) @@ -166,9 +168,9 @@ private TripResDto toTripResDto(Trip trip) { } @Transactional - public void setGoalAmount(Long tripIdx, BigDecimal goalAmount) { + public void setExpectedAmount(Long tripIdx, BigDecimal expectedAmount) { Trip trip = tripRepository.findById(tripIdx) .orElseThrow(() -> new ApiException(ExceptionEnum.TRIP_NOT_FOUND)); - tripRepository.updateGoalAmount(tripIdx, goalAmount); + tripRepository.updateExpectedAmount(tripIdx, expectedAmount); } } diff --git a/src/main/java/com/hanaro/triptogether/tripPlace/service/TripPlaceService.java b/src/main/java/com/hanaro/triptogether/tripPlace/service/TripPlaceService.java index 1237963..820472c 100644 --- a/src/main/java/com/hanaro/triptogether/tripPlace/service/TripPlaceService.java +++ b/src/main/java/com/hanaro/triptogether/tripPlace/service/TripPlaceService.java @@ -74,7 +74,7 @@ public void updatePlace(Long trip_placeIdx, TripPlaceUpdateInfoReqDto dto) { Long tripIdx = tripPlace.getTrip().getTripIdx(); //goalAmount 계산 및 설정 - tripService.setGoalAmount(tripIdx, tripPlaceRepository.getSumPlaceAmountByTripIdx(tripIdx)); + tripService.setExpectedAmount(tripIdx, tripPlaceRepository.getSumPlaceAmountByTripIdx(tripIdx)); } @Transactional @@ -180,7 +180,7 @@ public void updateTripPlace(Long tripIdx, TripPlaceUpdateReqDto reqDto) { } //goalAmount 계산 및 설정 - tripService.setGoalAmount(tripIdx, tripPlaceRepository.getSumPlaceAmountByTripIdx(tripIdx)); + tripService.setExpectedAmount(tripIdx, tripPlaceRepository.getSumPlaceAmountByTripIdx(tripIdx)); }