-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added TypesController for get all types and statuses
- Loading branch information
1 parent
0bb0cc4
commit 966e93c
Showing
16 changed files
with
206 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/main/java/org/example/bookingappliation/controller/TypesController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.example.bookingappliation.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.example.bookingappliation.dto.accommodations.response.AccommodationTypeDto; | ||
import org.example.bookingappliation.dto.accommodations.response.AmenityTypeDto; | ||
import org.example.bookingappliation.dto.accommodations.response.SizeTypeDto; | ||
import org.example.bookingappliation.dto.bookingstatuses.response.BookingStatusDto; | ||
import org.example.bookingappliation.dto.paymentstatuses.response.PaymentStatusDto; | ||
import org.example.bookingappliation.service.AccommodationTypeService; | ||
import org.example.bookingappliation.service.AmenityTypeService; | ||
import org.example.bookingappliation.service.BookingStatusService; | ||
import org.example.bookingappliation.service.PaymentStatusService; | ||
import org.example.bookingappliation.service.SizeTypeService; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Tag(name = "Types manage", description = "Endpoints for get type") | ||
@RestController | ||
@RequestMapping(value = "/types") | ||
@RequiredArgsConstructor | ||
public class TypesController { | ||
private final AccommodationTypeService accommodationTypeService; | ||
private final AmenityTypeService amenityTypeService; | ||
private final SizeTypeService sizeTypeService; | ||
private final PaymentStatusService paymentStatusService; | ||
private final BookingStatusService bookingStatusService; | ||
|
||
@GetMapping("/accommodation") | ||
@Operation(summary = "Get all accommodation types", | ||
description = "Get all accommodation types dto for front end") | ||
public List<AccommodationTypeDto> getAllAccommodationTypes() { | ||
return accommodationTypeService.getAll(); | ||
} | ||
|
||
@GetMapping("/amenity") | ||
@Operation(summary = "Get all amenity types", | ||
description = "Get all amenity types dto for front end") | ||
public List<AmenityTypeDto> getAllAmenityTypes() { | ||
return amenityTypeService.getAll(); | ||
} | ||
|
||
@GetMapping("/size") | ||
@Operation(summary = "Get all size types", | ||
description = "Get all size types dto for front end") | ||
public List<SizeTypeDto> getAllSizeTypes() { | ||
return sizeTypeService.getAlL(); | ||
} | ||
|
||
@GetMapping("/payment-status") | ||
@Operation(summary = "Get all payment status", | ||
description = "Get all payment status dto for front end") | ||
public List<PaymentStatusDto> getAllPaymentStatuses() { | ||
return paymentStatusService.getAll(); | ||
} | ||
|
||
@GetMapping("/booking-status") | ||
@Operation(summary = "Get all booking status", | ||
description = "Get all booking status dto for front end") | ||
public List<BookingStatusDto> getAllBookingStatuses() { | ||
return bookingStatusService.getAll(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/org/example/bookingappliation/dto/roletypes/response/RoleTypeDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.example.bookingappliation.dto.roletypes.response; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class RoleTypeDto { | ||
private Long id; | ||
private String name; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/org/example/bookingappliation/mapper/RoleTypeMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.example.bookingappliation.mapper; | ||
|
||
import org.example.bookingappliation.config.MapperConfig; | ||
import org.example.bookingappliation.dto.roletypes.response.RoleTypeDto; | ||
import org.example.bookingappliation.model.user.RoleType; | ||
import org.mapstruct.Mapper; | ||
|
||
@Mapper(config = MapperConfig.class) | ||
public interface RoleTypeMapper { | ||
RoleTypeDto toDto(RoleType roleType); | ||
} |
16 changes: 1 addition & 15 deletions
16
src/main/java/org/example/bookingappliation/mapper/UserMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
src/main/java/org/example/bookingappliation/service/AccommodationTypeService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package org.example.bookingappliation.service; | ||
|
||
import org.example.bookingappliation.model.accommodation.AccommodationType; | ||
import java.util.List; | ||
import org.example.bookingappliation.dto.accommodations.response.AccommodationTypeDto; | ||
|
||
public interface AccommodationTypeService { | ||
AccommodationType getById(Long id); | ||
List<AccommodationTypeDto> getAll(); | ||
} |
5 changes: 3 additions & 2 deletions
5
src/main/java/org/example/bookingappliation/service/AmenityTypeService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package org.example.bookingappliation.service; | ||
|
||
import org.example.bookingappliation.model.accommodation.AmenityType; | ||
import java.util.List; | ||
import org.example.bookingappliation.dto.accommodations.response.AmenityTypeDto; | ||
|
||
public interface AmenityTypeService { | ||
AmenityType getById(Long id); | ||
List<AmenityTypeDto> getAll(); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/org/example/bookingappliation/service/BookingStatusService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.example.bookingappliation.service; | ||
|
||
import java.util.List; | ||
import org.example.bookingappliation.dto.bookingstatuses.response.BookingStatusDto; | ||
|
||
public interface BookingStatusService { | ||
List<BookingStatusDto> getAll(); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/org/example/bookingappliation/service/PaymentStatusService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.example.bookingappliation.service; | ||
|
||
import java.util.List; | ||
import org.example.bookingappliation.dto.paymentstatuses.response.PaymentStatusDto; | ||
|
||
public interface PaymentStatusService { | ||
List<PaymentStatusDto> getAll(); | ||
} |
5 changes: 3 additions & 2 deletions
5
src/main/java/org/example/bookingappliation/service/SizeTypeService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package org.example.bookingappliation.service; | ||
|
||
import org.example.bookingappliation.model.accommodation.SizeType; | ||
import java.util.List; | ||
import org.example.bookingappliation.dto.accommodations.response.SizeTypeDto; | ||
|
||
public interface SizeTypeService { | ||
SizeType getById(Long id); | ||
List<SizeTypeDto> getAlL(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/org/example/bookingappliation/service/impl/BookingStatusServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.example.bookingappliation.service.impl; | ||
|
||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.example.bookingappliation.dto.bookingstatuses.response.BookingStatusDto; | ||
import org.example.bookingappliation.exception.repository.EntityNotFoundException; | ||
import org.example.bookingappliation.mapper.BookingStatusMapper; | ||
import org.example.bookingappliation.model.booking.BookingStatus; | ||
import org.example.bookingappliation.repository.bookingstatus.BookingStatusRepository; | ||
import org.example.bookingappliation.service.BookingStatusService; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class BookingStatusServiceImpl implements BookingStatusService { | ||
private final BookingStatusRepository bookingStatusRepository; | ||
private final BookingStatusMapper bookingStatusMapper; | ||
|
||
@Override | ||
public List<BookingStatusDto> getAll() { | ||
List<BookingStatus> listOfTypes = bookingStatusRepository.findAll(); | ||
if (listOfTypes.isEmpty()) { | ||
throw new EntityNotFoundException("Cant find any booking status"); | ||
} | ||
return listOfTypes.stream() | ||
.map(bookingStatusMapper::toDto) | ||
.toList(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/org/example/bookingappliation/service/impl/PaymentStatusServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.example.bookingappliation.service.impl; | ||
|
||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.example.bookingappliation.dto.paymentstatuses.response.PaymentStatusDto; | ||
import org.example.bookingappliation.exception.repository.EntityNotFoundException; | ||
import org.example.bookingappliation.mapper.PaymentStatusMapper; | ||
import org.example.bookingappliation.model.payment.PaymentStatus; | ||
import org.example.bookingappliation.repository.paymentstatus.PaymentStatusRepository; | ||
import org.example.bookingappliation.service.PaymentStatusService; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class PaymentStatusServiceImpl implements PaymentStatusService { | ||
private final PaymentStatusRepository paymentStatusRepository; | ||
private final PaymentStatusMapper paymentStatusMapper; | ||
|
||
@Override | ||
public List<PaymentStatusDto> getAll() { | ||
List<PaymentStatus> listOfTypes = paymentStatusRepository.findAll(); | ||
if (listOfTypes.isEmpty()) { | ||
throw new EntityNotFoundException("Cant find any payment status"); | ||
} | ||
return listOfTypes.stream() | ||
.map(paymentStatusMapper::toDto) | ||
.toList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters