package com.qmth.themis.business.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
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 java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @Description: 考试场次 服务类
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/6/25
 */
public interface TEExamActivityService extends IService<TEExamActivity> {

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

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

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

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

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

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

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

    /**
     * 获取考试待考列表
     *
     * @param examActivityId
     * @param examStudentId
     * @param courseCode
     * @param prefix
     * @param recordId
     * @return
     */
    public TEExamActivityDto getWaitingExam(Long examActivityId, Long examStudentId, String courseCode, String prefix, Long recordId);

    /**
     * 获取场次缓存
     *
     * @param examActivityId
     * @return
     */
    ExamActivityCacheBean getExamActivityCacheBean(Long examActivityId);

    /**
     * 更新场次缓存
     *
     * @param examActivityId
     * @return
     */
    ExamActivityCacheBean updateExamActivityCacheBean(Long examActivityId);

    /**
     * 删除场次缓存
     *
     * @param examActivityId
     */
    void deleteExamActivityCacheBean(Long examActivityId);

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

    void saveExamActivity(List<TEExamActivity> teExamActivityList);

    List<Long> findExamIdToday();

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

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