package com.fs.qw.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fs.course.domain.FsCourseWatchLog;
import com.fs.qw.domain.HyWorkTask;
import com.fs.qw.domain.QwWorkTask;
import com.fs.qw.param.QwWorkTaskListParam;
import com.fs.qw.vo.QwWorkTaskListVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

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

/**
 * 企微任务看板Mapper接口
 *
 * @author fs
 * @date 2025-03-18
 */
public interface HyWorkTaskMapper extends BaseMapper<HyWorkTask>{
    /**
     * 查询企微任务看板
     *
     * @param id 企微任务看板主键
     * @return 企微任务看板
     */
    HyWorkTask selectHyWorkTaskById(Long id);

    /**
     * 查询企微任务看板列表
     *
     * @param qwWorkTask 企微任务看板
     * @return 企微任务看板集合
     */
    List<HyWorkTask> selectHyWorkTaskList(HyWorkTask qwWorkTask);

    /**
     * 新增企微任务看板
     *
     * @param qwWorkTask 企微任务看板
     * @return 结果
     */
    int insertHyWorkTask(HyWorkTask qwWorkTask);

    /**
     * 修改企微任务看板
     *
     * @param qwWorkTask 企微任务看板
     * @return 结果
     */
    int updateHyWorkTask(HyWorkTask qwWorkTask);

    /**
     * 删除企微任务看板
     *
     * @param id 企微任务看板主键
     * @return 结果
     */
    int deleteHyWorkTaskById(Long id);

    /**
     * 批量删除企微任务看板
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    int deleteHyWorkTaskByIds(Long[] ids);

    void insertQwWorkTaskBatch(@Param("qwWorkTasks")List<HyWorkTask> qwWorkTasks);

    List<QwWorkTaskListVO> selectHyWorkTaskListVONew(QwWorkTaskListParam qwWorkTask);

    @Select("select ext_id from hy_work_task where type=2 and DATE(create_time) = CURDATE() ")
    List<Long> selectHyWorkTaskByType();

    @Select("select id,ext_id from hy_work_task where type=2 and status=0 and DATE(create_time) = CURDATE() ")
    List<QwWorkTask> selectHyWorkTaskByTypeStatus();
    @Update({
            "<script>",
            "UPDATE hy_work_task",
            "SET status = 2",
            "WHERE id IN",
            "<foreach item='id' collection='overIds' open='(' separator=',' close=')'>",
            "   #{id}",
            "</foreach>",
            "</script>"
    })
    void updateHyWorkTaskStatus(@Param("overIds")List<Long> overIds);

    @Select("select id,ext_id from hy_work_task where type=2 and status=1 and DATE(create_time) = CURDATE() ")
    List<QwWorkTask> selectHyWorkTaskByTypeStatus1();
    @Update({
            "<script>",
            "UPDATE hy_work_task",
            "SET status = 3",
            "WHERE id IN",
            "<foreach item='id' collection='overIds' open='(' separator=',' close=')'>",
            "   #{id}",
            "</foreach>",
            "</script>"
    })
    void updateHyWorkTaskStatus1(List<Long> overIds1);

    /**
     * 查询会员任务看板
     * @param params 参数
     * @return list
     */
    List<HyWorkTask> selectHyWorkTaskListByMap(@Param("params") Map<String, Object> params);

    Long selectHyWorkTaskListVONewCount(QwWorkTaskListParam qwWorkTask);

    void hyWorkTask();

    List<FsCourseWatchLog> hyWorkTaskGetInterruptedAndFirst();

}
