<?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.manage.mapper.RecordInspectionImgMapper">
    
    <resultMap type="RecordInspectionImg" id="RecordInspectionImgResult">
        <result property="inspectionId"    column="inspection_id"    />
        <result property="taskId"    column="task_id"    />
        <result property="imgPath"    column="img_path"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectRecordInspectionImgVo">
        select inspection_id, task_id, img_path, create_by, create_time from record_inspection_img
    </sql>

    <select id="selectRecordInspectionImgList" parameterType="RecordInspectionImg" resultMap="RecordInspectionImgResult">
        <include refid="selectRecordInspectionImgVo"/>
        <where>  
            <if test="inspectionId != null "> and inspection_id = #{inspectionId}</if>
            <if test="taskId != null "> and task_id = #{taskId}</if>
            <if test="imgPath != null  and imgPath != ''"> and img_path = #{imgPath}</if>
        </where>
    </select>
    
    <select id="selectRecordInspectionImgByInspectionId" parameterType="Long" resultMap="RecordInspectionImgResult">
        <include refid="selectRecordInspectionImgVo"/>
        where inspection_id = #{inspectionId}
    </select>
        
    <insert id="insertRecordInspectionImg" parameterType="RecordInspectionImg">
        insert into record_inspection_img
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inspectionId != null">inspection_id,</if>
            <if test="taskId != null">task_id,</if>
            <if test="imgPath != null">img_path,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="inspectionId != null">#{inspectionId},</if>
            <if test="taskId != null">#{taskId},</if>
            <if test="imgPath != null">#{imgPath},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateRecordInspectionImg" parameterType="RecordInspectionImg">
        update record_inspection_img
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskId != null">task_id = #{taskId},</if>
            <if test="imgPath != null">img_path = #{imgPath},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where inspection_id = #{inspectionId}
    </update>

    <delete id="deleteRecordInspectionImgByInspectionId" parameterType="Long">
        delete from record_inspection_img where inspection_id = #{inspectionId}
    </delete>

    <delete id="deleteRecordInspectionImgByInspectionIds" parameterType="String">
        delete from record_inspection_img where inspection_id in 
        <foreach item="inspectionId" collection="array" open="(" separator="," close=")">
            #{inspectionId}
        </foreach>
    </delete>

</mapper>