Class HolidayServiceImpl
java.lang.Object
com.app.service.impl.HolidayServiceImpl
- All Implemented Interfaces:
HolidayService
Service responsible for handling business logic related to holidays.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchangeStatus
(Long id, Status status) Changes the status of an existing holiday request.createHoliday
(CreateHolidayDto createHolidayDto, String token) Creates a new holiday request for a user.getHolidayDto
(Long id) Retrieves a holiday DTO by its ID.getHolidays
(HolidaySpecificationDto holidaySpecificationDto) Retrieves holidays matching given specification criteria.getHolidaysByDate
(String token, LocalDateTime startDate, LocalDateTime endDate) Retrieves holidays for a user within a date range.
-
Constructor Details
-
HolidayServiceImpl
public HolidayServiceImpl()
-
-
Method Details
-
createHoliday
Creates a new holiday request for a user.- Specified by:
createHoliday
in interfaceHolidayService
- Parameters:
createHolidayDto
- Data transfer object containing holiday details.token
- Authentication token to identify the user.- Returns:
- The ID of the created holiday entity.
- Throws:
IllegalArgumentException
- if the holiday overlaps with an existing one or the user doesn't have enough holiday hours.jakarta.persistence.EntityNotFoundException
- if the user is not found.
-
changeStatus
Changes the status of an existing holiday request.- Specified by:
changeStatus
in interfaceHolidayService
- Parameters:
id
- The ID of the holiday entity.status
- The new status to be set.- Returns:
- The ID of the updated holiday entity.
- Throws:
IllegalArgumentException
- if the status parameter is null.jakarta.persistence.EntityNotFoundException
- if the holiday or user is not found.
-
getHolidayDto
Retrieves a holiday DTO by its ID.- Specified by:
getHolidayDto
in interfaceHolidayService
- Parameters:
id
- The ID of the holiday.- Returns:
- HolidayDto containing holiday details.
- Throws:
jakarta.persistence.EntityNotFoundException
- if the holiday is not found.
-
getHolidaysByDate
public List<HolidayDto> getHolidaysByDate(String token, LocalDateTime startDate, LocalDateTime endDate) Retrieves holidays for a user within a date range.- Specified by:
getHolidaysByDate
in interfaceHolidayService
- Parameters:
token
- Authentication token to identify the user.startDate
- Start date of the range.endDate
- End date of the range.- Returns:
- List of HolidayDto objects matching the criteria.
-
getHolidays
Retrieves holidays matching given specification criteria.- Specified by:
getHolidays
in interfaceHolidayService
- Parameters:
holidaySpecificationDto
- Specification DTO with filter criteria.- Returns:
- List of HolidayDto objects matching the filter.
- Throws:
IllegalArgumentException
- if the specification DTO is null.
-