package com.qmth.themis.business.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qmth.themis.business.dto.response.TEExamActivityDto;
import com.qmth.themis.business.dto.response.TEExamActivityQueryDto;
import com.qmth.themis.business.dto.response.TEExamActivityWaitDto;
import com.qmth.themis.business.entity.TEExamActivity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

/**
 * @Description: 考试场次 Mapper 接口
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/6/25
 */
@Mapper
public interface TEExamActivityMapper extends BaseMapper<TEExamActivity> {

    /**
     * 表是否存在
     *
     * @param tableName
     * @param schema
     * @return
     */
    public Integer existTable(@Param("tableName") String tableName, @Param("schema") String schema);

    /**
     * 删除表
     *
     * @param tableName
     */
    public void dropTable(@Param("tableName") String tableName);

    /**
     * 创建表
     *
     * @param tableName
     */
    public void createNewTable(@Param("tableName") String tableName);

    /**
     * 新插数据
     *
     * @param tableName
     * @param teExamActivity
     */
    public void insertInfo(@Param("tableName") String tableName, @Param("TEExamActivity") TEExamActivity teExamActivity);

    /**
     * 查询所有数据
     *
     * @param iPage
     * @param tableName
     * @return
     */
    public IPage<TEExamActivity> selectListPage(IPage<Map> iPage, @Param("tableName") String tableName);

    /**
     * 查询考场场次信息
     *
     * @param iPage
     * @param id
     * @param examId
     * @param code
     * @param startDate
     * @param finishDate
     * @return
     */
    public IPage<TEExamActivityQueryDto> examActivityQuery(IPage<Map> iPage, @Param("id") Long id, @Param("examId") Long examId, @Param("code") String code, @Param("startDate") Long startDate, @Param("finishDate") Long finishDate);

    /**
     * 获取考试待考列表
     *
     * @param studentId
     * @param examActivityIds
     * @param orgId
     * @return
     */
    public List<TEExamActivityWaitDto> getWaitingExam(@Param("studentId") Long studentId, @Param("examActivityIds") Set<Long> examActivityIds, @Param("orgId") Long orgId);

    /**
     * 获取考试待考列表
     *
     * @param examActivityId
     * @return
     */
    public TEExamActivityDto getWaitingExamByExamActivityId(@Param("examActivityId") Long examActivityId);

    public List<TEExamActivity> findByExamIdAndOrgId(@Param("examId") Long examId, @Param("orgId") Long orgId);

    @SuppressWarnings("MybatisXMapperMethodInspection")
    public List<Map<String, Long>> findMinStartTimeAndMaxFinshTimeByExamId(@Param("examId") Long examId);

    public List<Long> findExamIdToday(@Param("startTime") Long startTime, @Param("endTime") Long endTime);

    /**
     * 查找当前待考列表
     *
     * @param startTime
     * @param endTime
     * @return
     */
    List<TEExamActivity> findCurrentExamActivity(@Param("startTime") Long startTime, @Param("endTime") Long endTime);

    /**
     * 根据天数获取待考列表
     *
     * @param day
     * @return
     */
    List<TEExamActivity> findWaitingExamList(@Param("day") Integer day);
}
