# HotelKpiWeekStartDayServiceImpl.java

    package cloud.wconnect.workperformance.service.hotelkpi.impl;

    import cloud.wconnect.workperformance.entity.hotelkpi.HotelKpiWeekStartDay;
    import cloud.wconnect.workperformance.mapper.hotelkpi.HotelKpiWeekStartDayMapper;
    import cloud.wconnect.workperformance.service.hotelkpi.IHotelKpiWeekStartDayService;
    import com.baomidou.dynamic.datasource.annotation.DS;
    import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
    import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.stereotype.Service;

    import java.time.DayOfWeek;
    import java.util.Objects;

    /**
     * <p>
     * Hotel KPI 周起始日 服务实现类
     * </p>
     *
     * @author zc
     * @since 2025-02-25
     */
    @Service
    @DS("work_performance")
    public class HotelKpiWeekStartDayServiceImpl extends ServiceImpl<HotelKpiWeekStartDayMapper, HotelKpiWeekStartDay> implements IHotelKpiWeekStartDayService {

        @Value("${default.first-day.hotel-kpi}")
        private Integer defaultWeekStartDay;

        /**
         * 获取周起始日
         *
         * @param propertyId 资产 id
         * @return DayOfWeek
         * @author zc
         * @date 2025/2/25
         */
        @Override
        public DayOfWeek getWeekStartDay(int propertyId) {
            HotelKpiWeekStartDay weekStartDay = getOne(new LambdaQueryWrapper<HotelKpiWeekStartDay>()
                    .eq(HotelKpiWeekStartDay::getPropertyId, propertyId));
            int dayOfWeek = Objects.isNull(weekStartDay) ? defaultWeekStartDay : weekStartDay.getWeekStartDay();
            return DayOfWeek.of(dayOfWeek);
        }
    }