package org.dromara.main.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.main.domain.MainExamApply;

public interface MainExamApplyMapper extends BaseMapperPlus<MainExamApply, MainExamApply> {

    @Select("SELECT * FROM main_exam_apply WHERE evaluation_id = #{evaluationId} AND tenant_id = #{tenantId} AND student_id = #{studentId} LIMIT 1")
    MainExamApply selectAnyByUniqueKey(@Param("evaluationId") Long evaluationId,
                                       @Param("tenantId") String tenantId,
                                       @Param("studentId") Long studentId);

    @Update("UPDATE main_exam_apply SET del_flag = '0', apply_source = '3', apply_status = '0', schedule_start_time = NOW(), deadline_time = NULL, max_attempt_count = 1, finished_time = NULL, final_result = NULL, update_time = NOW() WHERE id = #{id}")
    int restoreDeletedApply(@Param("id") Long id);
}
