package org.dromara.zhishu.mapper;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import org.apache.ibatis.annotations.Param;
import org.dromara.zhishu.domain.RunningTask;
import org.dromara.zhishu.domain.vo.RunningTaskNumVo;
import org.dromara.zhishu.domain.vo.RunningTaskVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;

import java.util.List;
import java.util.Map;

/**
 * 执行的任务Mapper接口
 *
 * @author yxy
 * @date 2025-07-23
 */
public interface RunningTaskMapper  {

    RunningTask selectById(Long id);

    /**
     * 查看任务日志
     * @param taskId
     * @return
     */
    @InterceptorIgnore(tenantLine = "true")
    List<Map<String, Object>> selectLogByTaskId(Long taskId);


    @InterceptorIgnore(tenantLine = "true")
    List<Map> selectGetShopGoodsList(@Param("shopId")Long shopId,@Param("pageNum") Long pageNum,@Param("pageSize") Long pageSize);

    @InterceptorIgnore(tenantLine = "true")
    Long selectGetShopGoodsNum(Long shopId);


    @InterceptorIgnore(tenantLine = "true")
    Map selectTaskStatus();

    @InterceptorIgnore(tenantLine = "true")
    List<RunningTaskNumVo> selectTaskAllNum(Long taskId);

    @InterceptorIgnore(tenantLine = "true")
    Long selectTaskIsRunning(Long taskId);


    @InterceptorIgnore(tenantLine = "true")
    Long selectShopTaskByGetShopGoods(Long shopId);

    @InterceptorIgnore(tenantLine = "true")
    Long selectTaskStatusByTaskType(@Param("shopId") Long shopId,@Param("taskType") String taskType);


    @InterceptorIgnore(tenantLine = "true")
    Long selectTaskStatusRunningCount();

    @InterceptorIgnore(tenantLine = "true")
    List<Map> selectTaskByGroupShopMd5();

    @InterceptorIgnore(tenantLine = "true")
    List<Map> selectTaskGroupShop(String taskType);


    @InterceptorIgnore(tenantLine = "true")
    List<RunningTaskNumVo> selectTaskShopNum(@Param("taskId") Long taskId,@Param("shopId") Long shopId);

    @InterceptorIgnore(tenantLine = "true")
    int insert(RunningTask runningTask);

    /**
     * 批量插入运行任务记录（如果需要也可以加上租户忽略）
     * @param list 任务列表
     * @return 影响行数
     */
    @InterceptorIgnore(tenantLine = "true")
    int batchInsert(List<RunningTask> list);

    @InterceptorIgnore(tenantLine = "true")
    int update(RunningTask runningTask);


    @InterceptorIgnore(tenantLine = "true")
    Boolean updataStatus(@Param("tableName") String tableName, @Param("taskId") Long shopId);

    @InterceptorIgnore(tenantLine = "true")
    Long selectTaskStatusByTaskTypeAndIsbn(Long shopId, String taskType, String isbn);
}
