<?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.ruoyi.learn.mapper.LearnQuestionCorrectMapper">
    
    <resultMap type="LearnQuestionCorrect" id="LearnQuestionCorrectResult">
        <result property="id"    column="id"    />
        <result property="questionId"    column="question_id"    />
        <result property="userId"    column="user_id"    />
        <result property="remark"    column="remark"    />
        <result property="state"    column="state"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectLearnQuestionCorrectVo">
        select id, question_id, user_id, remark, state, create_time, update_time from learn_question_correct
    </sql>

    <select id="selectLearnQuestionCorrectList" parameterType="LearnQuestionCorrect" resultMap="LearnQuestionCorrectResult">
        <include refid="selectLearnQuestionCorrectVo"/>
        <where>  
            <if test="questionId != null "> and question_id = #{questionId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="state != null "> and state = #{state}</if>
        </where>
    </select>
    
    <select id="selectLearnQuestionCorrectById" parameterType="Long" resultMap="LearnQuestionCorrectResult">
        <include refid="selectLearnQuestionCorrectVo"/>
        where id = #{id}
    </select>

    <insert id="insertLearnQuestionCorrect" parameterType="LearnQuestionCorrect" useGeneratedKeys="true" keyProperty="id">
        insert into learn_question_correct
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="questionId != null">question_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="remark != null and remark != ''">remark,</if>
            <if test="state != null">state,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="questionId != null">#{questionId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="remark != null and remark != ''">#{remark},</if>
            <if test="state != null">#{state},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateLearnQuestionCorrect" parameterType="LearnQuestionCorrect">
        update learn_question_correct
        <trim prefix="SET" suffixOverrides=",">
            <if test="questionId != null">question_id = #{questionId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="remark != null and remark != ''">remark = #{remark},</if>
            <if test="state != null">state = #{state},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteLearnQuestionCorrectById" parameterType="Long">
        delete from learn_question_correct where id = #{id}
    </delete>

    <delete id="deleteLearnQuestionCorrectByIds" parameterType="String">
        delete from learn_question_correct where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>