# PastReservationIntervalDayServiceImpl.java

    package cloud.wconnect.frontoffice.service.pastreservation.impl;

    import cloud.wconnect.commonlib.cons.BaseErrorCodeEnum;
    import cloud.wconnect.commonlib.cons.CommonErrorI18nConstant;
    import cloud.wconnect.commonlib.exception.BadRequestException;
    import cloud.wconnect.frontoffice.entity.pastreservation.PastReservationIntervalDay;
    import cloud.wconnect.frontoffice.mapper.pastreservation.PastReservationIntervalDayMapper;
    import cloud.wconnect.frontoffice.service.pastreservation.IPastReservationIntervalDayService;
    import com.baomidou.dynamic.datasource.annotation.DS;
    import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
    import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
    import org.springframework.stereotype.Service;

    import java.util.Objects;

    /**
     * <p>
     * 间隔天数设置 服务实现类
     * </p>
     *
     * @author yyt
     * @since 2024-10-01
     */
    @Service
    @DS("logbook")
    public class PastReservationIntervalDayServiceImpl extends ServiceImpl<PastReservationIntervalDayMapper, PastReservationIntervalDay> implements IPastReservationIntervalDayService {

        /**
         * 获取间隔天数设置
         *
         * @param propertyId 资产id
         * @return 间隔天数设置
         * @author yyt
         * @date 2024/10/1
         **/
        @Override
        public PastReservationIntervalDay getByPropertyId(Integer propertyId) {
            return getOne(new QueryWrapper<PastReservationIntervalDay>().lambda().eq(PastReservationIntervalDay::getPropertyId, propertyId));
        }

        /**
         * 获取间隔天数设置
         *
         * @param propertyId 资产id
         * @return 间隔天数设置
         * @author yyt
         * @date 2024/10/1
         **/
        @Override
        public PastReservationIntervalDay getByPropertyIdForUpdate(Integer propertyId) {
            return getOne(new QueryWrapper<PastReservationIntervalDay>().lambda().eq(PastReservationIntervalDay::getPropertyId, propertyId)
                    .last("for update"));
        }

        /**
         * 检查间隔天数设置
         *
         * @param propertyId 资产id
         * @return 间隔天数设置
         * @author yyt
         * @date 2024/10/1
         **/
        @Override
        public PastReservationIntervalDay checkExistForUpdate(Integer propertyId) {
            PastReservationIntervalDay intervalDay = getOne(new QueryWrapper<PastReservationIntervalDay>().lambda().eq(PastReservationIntervalDay::getPropertyId, propertyId)
                    .last("for update"));
            if (Objects.isNull(intervalDay)) {
                throw new BadRequestException(CommonErrorI18nConstant.DATA_NOT_FOUND,
                        BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(), "please set interval days first");
            }
            return intervalDay;
        }

    }