package org.xyzh.crontab.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.dto.crontab.TbCrontabEmailRecipient;

import java.util.List;

/**
 * @description 定时任务邮件接收人访问层
 * @filename EmailRecipientMapper.java
 * @author yslg
 * @copyright xyzh
 * @since 2025-11-18
 */
@Mapper
public interface EmailRecipientMapper extends BaseMapper<TbCrontabEmailRecipient> {

    /**
     * @description 插入邮件接收人
     */
    int insertRecipient(@Param("recipient") TbCrontabEmailRecipient recipient);

    /**
     * @description 批量插入邮件接收人
     */
    int batchInsertRecipient(@Param("recipients") List<TbCrontabEmailRecipient> recipients);

    /**
     * @description 更新邮件接收人
     */
    int updateRecipient(@Param("recipient") TbCrontabEmailRecipient recipient);

    /**
     * @description 删除邮件接收人（逻辑删除）
     */
    int deleteRecipient(@Param("recipientId") String recipientId);

    /**
     * @description 根据接收人ID查询
     */
    TbCrontabEmailRecipient selectRecipientById(@Param("recipientId") String recipientId);

    /**
     * @description 根据任务ID查询接收人列表
     */
    List<TbCrontabEmailRecipient> selectRecipientsByTaskId(@Param("taskId") String taskId);


    /**
     * @description 分页查询邮件接收人
     */
    List<TbCrontabEmailRecipient> selectRecipientPage(@Param("filter") TbCrontabEmailRecipient filter, @Param("pageParam") PageParam pageParam);

    /**
     * @description 查询邮件接收人总数
     */
    int countSelectRecipient(@Param("filter") TbCrontabEmailRecipient filter);

    /**
     * @description 删除任务的所有接收人
     */
    int deleteRecipientsByTaskId(@Param("taskId") String taskId);
}