Skip to content

Commit

Permalink
Merge pull request #138 from Hanaro-trip-together-bank/feature/trip
Browse files Browse the repository at this point in the history
feat: 여행 일정 예상 비용 반영 완료
  • Loading branch information
lcw729 authored Jun 7, 2024
2 parents 772f6a3 + 82d0020 commit d0defef
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/hanaro/triptogether/trip/domain/Trip.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
public interface TripRepository extends JpaRepository<Trip, Long> {
List<Trip> 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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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())
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -180,7 +180,7 @@ public void updateTripPlace(Long tripIdx, TripPlaceUpdateReqDto reqDto) {
}

//goalAmount 계산 및 설정
tripService.setGoalAmount(tripIdx, tripPlaceRepository.getSumPlaceAmountByTripIdx(tripIdx));
tripService.setExpectedAmount(tripIdx, tripPlaceRepository.getSumPlaceAmountByTripIdx(tripIdx));

}

Expand Down

0 comments on commit d0defef

Please sign in to comment.