Skip to content

Commit

Permalink
Merge pull request #266 from PLADI-ALM/fix/PDS-112-returnResource
Browse files Browse the repository at this point in the history
[PDS-112/fix] 장비 및 차량 반납 시, 반납 시간으로 종료 시간 변경
  • Loading branch information
chaerlo127 authored Dec 1, 2023
2 parents 904c535 + bf6e564 commit be59042
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.time.LocalTime;

@Entity
@Getter
Expand Down Expand Up @@ -71,10 +72,11 @@ public boolean checkBookingStatus(BookingStatus bookingStatus) {
return status.equals(bookingStatus);
}

public void returnBookingCar(String remark) {
public void returnBookingCar(String remark, LocalDateTime now) {
changeBookingStatus(BookingStatus.FINISHED);
this.returnDate = LocalDateTime.now();
this.returnDate = now;
this.remark = remark;
this.endDate = LocalDateTime.of(now.toLocalDate(), LocalTime.of(now.getHour(), 0).plusHours(1));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.time.LocalTime;

@Entity
@Getter
Expand Down Expand Up @@ -64,10 +65,11 @@ public static ResourceBooking toDto(User user, Resource resource, ProductReq pro
.build();
}

public void returnBookingResource(String remark) {
public void returnBookingResource(String remark, LocalDateTime now) {
changeBookingStatus(BookingStatus.FINISHED);
this.returnDate = LocalDateTime.now();
this.returnDate = now;
this.remark = remark;
this.endDate = LocalDateTime.of(now.toLocalDate(), LocalTime.of(now.getHour(), 0).plusHours(1));
}

public void changeBookingStatus(BookingStatus bookingStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private void returnBookingCar(CarBooking carBooking, ReturnProductReq request) {
throw new BaseException(BaseResponseCode.MUST_BE_IN_USE);

// 차량 반납
carBooking.returnBookingCar(request.getRemark());
carBooking.returnBookingCar(request.getRemark(), LocalDateTime.now());
carBookingRepository.save(carBooking);

Car car = carBooking.getCar();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void returnBookingResource(ResourceBooking resourceBooking, ReturnProduc
throw new BaseException(BaseResponseCode.MUST_BE_IN_USE);

// 장비 반납
resourceBooking.returnBookingResource(request.getRemark());
resourceBooking.returnBookingResource(request.getRemark(), LocalDateTime.now());
resourceBookingRepository.save(resourceBooking);

Resource resource = resourceBooking.getResource();
Expand Down

0 comments on commit be59042

Please sign in to comment.