# BudgetDatabaseConfigNotifyDateServiceImpl.java

    package cloud.wconnect.rateshop.service.budgetdatabase.impl;

    import cloud.wconnect.commonlib.component.BeanMapper;
    import cloud.wconnect.commonlib.util.DateTimeUtils;
    import cloud.wconnect.rateshop.entity.budgetdatabase.BudgetDatabaseConfigNotifyDate;
    import cloud.wconnect.rateshop.mapper.budgetdatabase.BudgetDatabaseConfigNotifyDateMapper;
    import cloud.wconnect.rateshop.pojo.dto.budgetdatabase.StartNotifyDateDTO;
    import cloud.wconnect.rateshop.pojo.dto.budgetdatabase.UpdateStartNotifyDateDTO;
    import cloud.wconnect.rateshop.service.budgetdatabase.IBudgetDatabaseConfigNotifyDateService;
    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.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;

    import java.util.Objects;

    /**
     * <p>
     *  服务实现类
     * </p>
     *
     * @author yyt
     * @since 2025-08-13
     */
    @Service
    @DS("rate_shop")
    public class BudgetDatabaseConfigNotifyDateServiceImpl extends ServiceImpl<BudgetDatabaseConfigNotifyDateMapper, BudgetDatabaseConfigNotifyDate> implements IBudgetDatabaseConfigNotifyDateService {

        @Autowired
        private BeanMapper beanMapper;

        /**
         * 获取起始通知日期
         *
         * @param propertyId 资产 id
         * @return 起始通知日期
         * @author yyt
         * @date 2025/8/16
         **/
        @Override
        public BudgetDatabaseConfigNotifyDate get(Integer propertyId) {
            return getOne(new QueryWrapper<BudgetDatabaseConfigNotifyDate>().lambda()
                    .eq(BudgetDatabaseConfigNotifyDate::getPropertyId, propertyId));
        }

        /**
         * 获取起始通知日期
         *
         * @param propertyId 资产 id
         * @return 起始通知日期
         * @author yyt
         * @date 2025/8/16
         **/
        @Override
        public StartNotifyDateDTO getDTO(Integer propertyId) {
            BudgetDatabaseConfigNotifyDate config = get(propertyId);
            if (Objects.isNull(config)) {
                return new StartNotifyDateDTO();
            }
            return beanMapper.map(config, StartNotifyDateDTO.class);
        }

        /**
         * 保存到期通知开始日
         *
         * @param propertyId               资产 id
         * @param updateStartNotifyDateDTO 起始通知日期
         * @param userId                   资产 id
         * @author yyt
         * @date 2025/8/16
         **/
        @Override
        public void save(Integer propertyId, UpdateStartNotifyDateDTO updateStartNotifyDateDTO, int userId) {
            baseMapper.saveOrUpdate(new BudgetDatabaseConfigNotifyDate()
                    .setPropertyId(propertyId)
                    .setDate(updateStartNotifyDateDTO.getDate())
                    .setUpdatedBy(userId)
                    .setUpdatedTime(DateTimeUtils.nowTimestamp()));
        }

    }