# FirstDayServiceImpl.java

    package cloud.wconnect.workperformance.service.sva.setting.impl;

    import cloud.wconnect.commonlib.util.DateTimeUtils;
    import cloud.wconnect.workperformance.entity.sva.setting.FirstDay;
    import cloud.wconnect.workperformance.mapper.sva.setting.FirstDayMapper;
    import cloud.wconnect.workperformance.pojo.dto.common.FirstDayDTO;
    import cloud.wconnect.workperformance.service.sva.setting.IFirstDayService;
    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 org.springframework.transaction.annotation.Transactional;

    import java.util.List;
    import java.util.Objects;

    /**
     * <p>
     * 服务实现类：周起始日
     * </p>
     *
     * @author zc
     * @since 2023-03-20
     */
    @Service
    @DS("work_performance")
    public class FirstDayServiceImpl extends ServiceImpl<FirstDayMapper, FirstDay> implements IFirstDayService {

        /**
         * 保存周起始日
         *
         * @param propertyId  资产 id
         * @param operatorId  操作人 id
         * @param firstDayDTO 周起始日
         * @author zc
         * @date 2023/3/20
         */
        @Override
        @Transactional(rollbackFor = Exception.class)
        public void save(int propertyId, int operatorId, FirstDayDTO firstDayDTO) {
            FirstDay firstDay = new FirstDay();
            firstDay.setFirstDay(firstDayDTO.getFirstDay());
            firstDay.setUpdateBy(operatorId);
            firstDay.setUpdateTime(DateTimeUtils.nowTimestamp());

            FirstDay originData = get(propertyId);
            if (Objects.isNull(originData)) {
                firstDay.setPropertyId(propertyId);
            } else {
                firstDay.setId(originData.getId());
            }
            saveOrUpdate(firstDay);
        }

        /**
         * 获取周起始日
         *
         * @param propertyId property id
         * @return 周起始日
         * @author zc
         * @date 2023/3/20
         */
        @Override
        public FirstDay get(int propertyId) {
            return getOne(new QueryWrapper<FirstDay>().lambda()
                    .eq(FirstDay::getPropertyId, propertyId));
        }

        /**
         * 获取周起始日集合
         *
         * @param propertyIds property id
         * @return 周起始日集合
         * @author zc
         * @date 2023/3/28
         */
        @Override
        public List<FirstDay> list(List<Integer> propertyIds) {
            return list(new QueryWrapper<FirstDay>().lambda()
                    .in(FirstDay::getPropertyId, propertyIds));
        }
    }