<?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.mxjb.mapper.MxjbWrongDetailMapper">
    
    <resultMap type="MxjbWrongDetail" id="MxjbWrongDetailResult">
        <result property="wrongDetailId"    column="wrong_detail_id"    />
        <result property="wrongId"    column="wrong_id"    />
        <result property="createdTime"    column="created_time"    />
        <result property="source"    column="source"    />
        <result property="state"    column="state"    />
        <result property="paperId"    column="paper_id"    />
        <result property="examineeId"    column="examinee_id"    />
    </resultMap>

    <sql id="selectMxjbWrongDetailVo">
        select wrong_detail_id, wrong_id, created_time, source, state, paper_id, examinee_id  from mxjb_wrong_detail
    </sql>

    <select id="selectMxjbWrongDetailList" parameterType="MxjbWrongDetail" resultMap="MxjbWrongDetailResult">
        <include refid="selectMxjbWrongDetailVo"/>
        <where>  
            <if test="wrongId != null "> and wrong_id = #{wrongId}</if>
            <if test="createdTime != null "> and created_time = #{createdTime}</if>
            <if test="source != null  and source != ''"> and source = #{source}</if>
            <if test="state != null "> and state = #{state}</if>
            <if test="paperId != null "> and paper_id = #{paperId}</if>
            <if test="examineeId != null "> and examinee_id = #{examineeId}</if>
        </where>
    </select>
    
    <select id="selectMxjbWrongDetailById" parameterType="Long" resultMap="MxjbWrongDetailResult">
        <include refid="selectMxjbWrongDetailVo"/>
        where wrong_detail_id = #{wrongDetailId}
    </select>
        
    <insert id="insertMxjbWrongDetail" parameterType="MxjbWrongDetail" useGeneratedKeys="true" keyProperty="wrongDetailId">
        insert into mxjb_wrong_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="wrongId != null">wrong_id,</if>
            <if test="createdTime != null">created_time,</if>
            <if test="source != null">source,</if>
            <if test="state != null">state,</if>
            <if test="paperId != null">paper_id,</if>
            <if test="examineeId != null">examinee_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="wrongId != null">#{wrongId},</if>
            <if test="createdTime != null">#{createdTime},</if>
            <if test="source != null">#{source},</if>
            <if test="state != null">#{state},</if>
            <if test="paperId != null">#{paperId},</if>
            <if test="examineeId != null">#{examineeId},</if>
         </trim>
    </insert>

    <update id="updateMxjbWrongDetail" parameterType="MxjbWrongDetail">
        update mxjb_wrong_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="wrongId != null">wrong_id = #{wrongId},</if>
            <if test="createdTime != null">created_time = #{createdTime},</if>
            <if test="source != null">source = #{source},</if>
            <if test="state != null">state = #{state},</if>
            <if test="paperId != null">paper_id = #{paperId},</if>
            <if test="examineeId != null">examinee_id = #{examineeId},</if>
        </trim>
        where wrong_detail_id = #{wrongDetailId}
    </update>

    <delete id="deleteMxjbWrongDetailById" parameterType="Long">
        delete from mxjb_wrong_detail where wrong_detail_id = #{wrongDetailId}
    </delete>

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