package com.ktg.iscs.service.impl;

import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ktg.common.core.text.Convert;
import com.ktg.common.utils.DateUtils;
import com.ktg.iscs.domain.IsMaterialsReminder;
import com.ktg.iscs.domain.dto.materialsReminder.MaterialsReminderPageDTO;
import com.ktg.iscs.domain.vo.materialsReminder.MaterialsReminderVO;
import com.ktg.iscs.mapper.IsMaterialsReminderMapper;
import com.ktg.iscs.service.IIsMaterialsReminderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 物资借出提醒Service业务层处理
 *
 * @author cgj
 * @date 2024-11-19
 */
@Service
public class IsMaterialsReminderServiceImpl extends ServiceImpl<IsMaterialsReminderMapper, IsMaterialsReminder> implements IIsMaterialsReminderService
{
    @Autowired
    private IsMaterialsReminderMapper isMaterialsReminderMapper;

    /**
     * 查询物资借出提醒
     *
     * @param recordId 物资借出提醒主键
     * @return 物资借出提醒
     */
    @Override
    public IsMaterialsReminder selectIsMaterialsReminderByRecordId(Long recordId)
    {
        return isMaterialsReminderMapper.selectIsMaterialsReminderByRecordId(recordId);
    }

    /**
     * 查询物资借出提醒列表
     *
     * @param isMaterialsReminder 物资借出提醒
     * @return 物资借出提醒
     */
    @Override
    public List<IsMaterialsReminder> selectIsMaterialsReminderList(IsMaterialsReminder isMaterialsReminder)
    {
        return isMaterialsReminderMapper.selectIsMaterialsReminderList(isMaterialsReminder);
    }

    /**
     * 新增物资借出提醒
     *
     * @param isMaterialsReminder 物资借出提醒
     * @return 结果
     */
    @Override
    public int insertIsMaterialsReminder(IsMaterialsReminder isMaterialsReminder)
    {
        isMaterialsReminder.setCreateTime(DateUtils.getNowDate());
        return isMaterialsReminderMapper.insertIsMaterialsReminder(isMaterialsReminder);
    }

    /**
     * 修改物资借出提醒
     *
     * @param isMaterialsReminder 物资借出提醒
     * @return 结果
     */
    @Override
    public int updateIsMaterialsReminder(IsMaterialsReminder isMaterialsReminder)
    {
        isMaterialsReminder.setUpdateTime(DateUtils.getNowDate());
        return isMaterialsReminderMapper.updateIsMaterialsReminder(isMaterialsReminder);
    }

    /**
     * 批量删除物资借出提醒
     *
     * @param recordIds 需要删除的物资借出提醒主键
     * @return 结果
     */
    @Override
    public int deleteIsMaterialsReminderByRecordIds(String recordIds)
    {
        Assert.notBlank(recordIds, "请选择需要删除的数据!");
        Long[] longIds = Convert.toLongArray(recordIds);
        return isMaterialsReminderMapper.deleteIsMaterialsReminderByRecordIds(longIds);
    }

    /**
     * 删除物资借出提醒信息
     *
     * @param recordId 物资借出提醒主键
     * @return 结果
     */
    @Override
    public int deleteIsMaterialsReminderByRecordId(Long recordId)
    {
        return isMaterialsReminderMapper.deleteIsMaterialsReminderByRecordId(recordId);
    }

    @Override
    public Page<MaterialsReminderVO> getIsMaterialsReminderPage(Page<IsMaterialsReminder> page, MaterialsReminderPageDTO dto) {
        return isMaterialsReminderMapper.getIsMaterialsReminderPage(page, dto);
    }
}
