<?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.record.mapper.RecordInspectionCabinetMapper">
    
    <resultMap type="RecordInspectionCabinet" id="RecordInspectionCabinetResult">
        <result property="objId"    column="obj_id"    />
        <result property="taskCode"    column="task_code"    />
        <result property="beginTime"    column="begin_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="filePath"    column="file_path"    />
        <result property="isFlag"    column="is_flag"    />
        <result property="remark"    column="remark"    />
        <result property="createdBy"    column="created_by"    />
        <result property="createdTime"    column="created_time"    />
        <result property="updatedBy"    column="updated_by"    />
        <result property="updatedTime"    column="updated_time"    />
    </resultMap>

    <sql id="selectRecordInspectionCabinetVo">
        select obj_id, task_code, begin_time, end_time, file_path, is_flag, remark, created_by, created_time, updated_by, updated_time from record_inspection_cabinet
    </sql>

    <select id="selectRecordInspectionCabinetList" parameterType="RecordInspectionCabinet" resultMap="RecordInspectionCabinetResult">
        <include refid="selectRecordInspectionCabinetVo"/>
        <where>  
            <if test="objId != null "> and obj_id = #{objId}</if>
            <if test="taskCode != null  and taskCode != ''"> and task_code = #{taskCode}</if>
            <if test="beginTime != null "> and begin_time = #{beginTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="filePath != null  and filePath != ''"> and file_path = #{filePath}</if>
            <if test="isFlag != null "> and is_flag = #{isFlag}</if>
            <if test="remark != null  and remark != ''"> and remark = #{remark}</if>
            <if test="createdBy != null  and createdBy != ''"> and created_by = #{createdBy}</if>
            <if test="params.beginCreatedTime != null and params.beginCreatedTime != '' and params.endCreatedTime != null and params.endCreatedTime != ''"> and created_time between #{params.beginCreatedTime} and #{params.endCreatedTime}</if>
            <if test="updatedBy != null  and updatedBy != ''"> and updated_by = #{updatedBy}</if>
            <if test="params.beginUpdatedTime != null and params.beginUpdatedTime != '' and params.endUpdatedTime != null and params.endUpdatedTime != ''"> and updated_time between #{params.beginUpdatedTime} and #{params.endUpdatedTime}</if>
        </where>
    </select>
    
    <select id="selectRecordInspectionCabinetByObjId" parameterType="Long" resultMap="RecordInspectionCabinetResult">
        <include refid="selectRecordInspectionCabinetVo"/>
        where obj_id = #{objId}
    </select>

    <insert id="insertRecordInspectionCabinet" parameterType="RecordInspectionCabinet" useGeneratedKeys="true" keyProperty="objId">
        insert into record_inspection_cabinet
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskCode != null and taskCode != ''">task_code,</if>
            <if test="beginTime != null">begin_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="filePath != null">file_path,</if>
            <if test="isFlag != null">is_flag,</if>
            <if test="remark != null">remark,</if>
            <if test="createdBy != null">created_by,</if>
            <if test="createdTime != null">created_time,</if>
            <if test="updatedBy != null">updated_by,</if>
            <if test="updatedTime != null">updated_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskCode != null and taskCode != ''">#{taskCode},</if>
            <if test="beginTime != null">#{beginTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="filePath != null">#{filePath},</if>
            <if test="isFlag != null">#{isFlag},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createdBy != null">#{createdBy},</if>
            <if test="createdTime != null">#{createdTime},</if>
            <if test="updatedBy != null">#{updatedBy},</if>
            <if test="updatedTime != null">#{updatedTime},</if>
         </trim>
    </insert>

    <update id="updateRecordInspectionCabinet" parameterType="RecordInspectionCabinet">
        update record_inspection_cabinet
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskCode != null and taskCode != ''">task_code = #{taskCode},</if>
            <if test="beginTime != null">begin_time = #{beginTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="filePath != null">file_path = #{filePath},</if>
            <if test="isFlag != null">is_flag = #{isFlag},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createdBy != null">created_by = #{createdBy},</if>
            <if test="createdTime != null">created_time = #{createdTime},</if>
            <if test="updatedBy != null">updated_by = #{updatedBy},</if>
            <if test="updatedTime != null">updated_time = #{updatedTime},</if>
        </trim>
        where obj_id = #{objId}
    </update>

    <delete id="deleteRecordInspectionCabinetByObjId" parameterType="Long">
        delete from record_inspection_cabinet where obj_id = #{objId}
    </delete>

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