Skip to content

Commit

Permalink
Merge pull request #111 from Hoang-Nguyen-Huy/PBS-84-Manage-Order-Ame…
Browse files Browse the repository at this point in the history
…nities

Pbs 84 manage order amenities
  • Loading branch information
nguyenhcp2004 authored Oct 26, 2024
2 parents b556036 + 01b4d20 commit bc8cebd
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,17 @@ public class OrderDetailAmenityController {
private final OrderService orderService;

@GetMapping("/page")
public ApiResponse<PaginationResponse<List<OrderDetailAmenityListResponse>>> getOrderDetailAndAmenity(
public PaginationResponse<List<OrderDetailAmenityListResponse>> getOrderDetailAndAmenity(
@RequestHeader("Authorization") String token,
@RequestParam String startDate,
@RequestParam String endDate,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size) {
@RequestParam(defaultValue = "10") int take) {
String accountId = accountService.extractAccountIdFromToken(token);
Account user = accountService.getAccountById(accountId);
LocalDateTime startDateTime = orderService.parseDateTime(startDate);
LocalDateTime endDateTime = orderService.parseDateTime(endDate);
return ApiResponse.<PaginationResponse<List<OrderDetailAmenityListResponse>>>builder()
.data(orderDetailService.getPagedOrderDetails(user, startDateTime, endDateTime, page, size))
.message("get paging order detail successfully")
.build();
return orderDetailService.getPagedOrderDetails(user, startDateTime, endDateTime, page, take);
}

@PostMapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ ApiResponse<List<BookedRoomDto>> getBookedRooms(@RequestHeader("Authorization")
.build();
}

@GetMapping("/booked-rooms/account")
ApiResponse<List<BookedRoomDto>> getBookedRoomsByAccountId(@RequestParam("accountId") String accountId) {
return ApiResponse.<List<BookedRoomDto>>builder()
.message("Các phòng đã đặt")
.data(roomService.getBookedRooms(accountId))
.build();
}

@GetMapping("/number-served-rooms-currently")
ApiResponse<Integer> countCurrentlyServedRooms() {
return ApiResponse.<Integer>builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
public class OrderDetailAmenityListResponse {
String id;
String customerId;
String customerName;
int buildingId;
String buildingAddress;
int roomId;
String roomName;
String orderId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
@Getter
public enum OrderDetailAmenityStatus {
Booked("Đã đặt"),
Paid("Đã thanh toán"),
Delivered("Đã giao"),
Canceled("Đã xóa");
Canceled("Đã hủy");

private final String description;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void createOrderDetailAmenity(OrderDetailAmenityRequest request) {
throw new RuntimeException("Order detail or amenity not found");
}
OrderDetailAmenity orderDetailAmenity = new OrderDetailAmenity();
orderDetailAmenity.setStatus(OrderDetailAmenityStatus.Booked);
orderDetailAmenity.setStatus(OrderDetailAmenityStatus.Paid);
orderDetailAmenity.setCreatedAt(LocalDateTime.now());
orderDetailAmenity.setUpdatedAt(LocalDateTime.now());
orderDetailAmenity.setId(UUID.randomUUID().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,14 @@ public PaginationResponse<List<OrderDetailAmenityListResponse>> getPagedOrderDet
.customerId(Optional.ofNullable(orderDetail.getCustomer())
.map(Account::getId)
.orElse(null))
.customerName(Optional.ofNullable(orderDetail.getCustomer())
.map(Account::getName)
.orElse(null))
.orderHandledId(Optional.ofNullable(orderDetail.getOrderHandler())
.map(Account::getId)
.orElse(null))
.buildingId(orderDetail.getBuilding().getId())
.buildingAddress(orderDetail.getBuilding().getAddress())
.roomId(orderDetail.getRoom().getId())
.roomName(orderDetail.getRoom().getName())
.orderId(orderDetail.getOrder().getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ public List<RoomAvailabilityDTO> getUnavailableRooms(LocalDateTime startTime, Lo

public List<BookedRoomDto> getBookedRooms(String customerId) {
LocalDateTime currentTime = LocalDateTime.now();
List<BookedRoomDto> bookedRoomDtos = roomRepository.findBookedRooms(currentTime, customerId);
return bookedRoomDtos;
return roomRepository.findBookedRooms(currentTime, customerId);
}

/*
Expand Down

0 comments on commit bc8cebd

Please sign in to comment.