<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.vote.system.mapper.VoteEvaluationTasksMapper">

    <resultMap id="BaseResultMap" type="com.vote.system.domain.VoteEvaluationTasks">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="submissionId" column="submission_id" jdbcType="BIGINT"/>
        <result property="judgeId" column="judge_id" jdbcType="VARCHAR"/>
        <result property="roundId" column="round_id" jdbcType="BIGINT"/>
        <result property="status" column="status" jdbcType="TINYINT"/>
        <result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
        <result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id
        ,submission_id,judge_id,
        status,created_at,updated_at
    </sql>
    <insert id="insertBatch">
        INSERT INTO vote_evaluation_tasks (submission_id, judge_id,round_id)
        VALUES
        <foreach collection="list" item="task" separator=",">
            (#{task.submissionId}, #{task.judgeId} , #{task.roundId})
        </foreach>
    </insert>

    <update id="updateBySubmissionId">
        UPDATE vote_evaluation_tasks
        SET status = 1
        WHERE judge_id = #{userId}
          AND submission_id = #{submissionId}
    </update>
</mapper>
