Class HolidayServiceImpl

java.lang.Object
com.app.service.impl.HolidayServiceImpl
All Implemented Interfaces:
HolidayService

@Service public class HolidayServiceImpl extends Object implements HolidayService
Service responsible for handling business logic related to holidays.
  • Constructor Details

    • HolidayServiceImpl

      public HolidayServiceImpl()
  • Method Details

    • createHoliday

      public Long createHoliday(CreateHolidayDto createHolidayDto, String token)
      Creates a new holiday request for a user.
      Specified by:
      createHoliday in interface HolidayService
      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

      public Long changeStatus(Long id, Status status)
      Changes the status of an existing holiday request.
      Specified by:
      changeStatus in interface HolidayService
      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

      public HolidayDto getHolidayDto(Long id)
      Retrieves a holiday DTO by its ID.
      Specified by:
      getHolidayDto in interface HolidayService
      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 interface HolidayService
      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

      public List<HolidayDto> getHolidays(HolidaySpecificationDto holidaySpecificationDto)
      Retrieves holidays matching given specification criteria.
      Specified by:
      getHolidays in interface HolidayService
      Parameters:
      holidaySpecificationDto - Specification DTO with filter criteria.
      Returns:
      List of HolidayDto objects matching the filter.
      Throws:
      IllegalArgumentException - if the specification DTO is null.