<?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.system.mapper.CheckPointRecordMapper">
    
    <resultMap type="CheckPointRecord" id="CheckPointRecordResult">
        <result property="checkPointRecordId"    column="check_point_record_id"    />
        <result property="checkPointManageId"    column="check_point_manage_id"    />
        <result property="dateTimeNum"    column="date_time_num"    />
        <result property="checkType"    column="check_type"    />
        <result property="checkTime"    column="check_time"    />
        <result property="checkAddress"    column="check_address"    />
        <result property="userName"    column="user_name"    />
        <result property="useId"    column="use_id"    />
        <result property="checkUserName"    column="check_user_name"    />
        <result property="checkUseId"    column="check_use_id"    />
        <result property="checkStaffId"    column="check_staff_id"    />
        <result property="checkUsePhone"    column="check_use_phone"    />
        <result property="checkResult"    column="check_result"    />
        <result property="checkResultDetails"    column="check_result_details"    />
        <result property="checkResultPhoto"    column="check_result_photo"    />
        <result property="checkResultTime"    column="check_result_time"    />
        <result property="checkStatus"    column="check_status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectCheckPointRecordVo">
        select check_point_record_id, check_point_manage_id, date_time_num,check_staff_id, check_type, check_time, check_address, user_name, use_id, check_user_name, check_use_id, check_use_phone, check_result, check_result_details, check_result_photo, check_result_time, check_status, create_by, create_time, update_by, update_time, remark from check_point_record
    </sql>

    <select id="selectCheckPointRecordList" parameterType="CheckPointRecord" resultMap="CheckPointRecordResult">
        <include refid="selectCheckPointRecordVo"/>
        <where>  
            <if test="checkPointManageId != null "> and check_point_manage_id = #{checkPointManageId}</if>
            <if test="dateTimeNum != null  and dateTimeNum != ''"> and date_time_num = #{dateTimeNum}</if>
            <if test="checkType != null  and checkType != ''"> and check_type = #{checkType}</if>
            <if test="checkTime != null "> and  date_format(check_time,'%Y%m%d') = date_format(#{checkTime},'%Y%m%d')</if>
            <if test="checkAddress != null  and checkAddress != ''"> and check_address = #{checkAddress}</if>
            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
            <if test="useId != null "> and use_id = #{useId}</if>
            <if test="checkUserName != null  and checkUserName != ''"> and check_user_name like concat('%', #{checkUserName}, '%')</if>
            <if test="checkUseId != null "> and check_use_id = #{checkUseId}</if>
            <if test="checkUsePhone != null  and checkUsePhone != ''"> and check_use_phone = #{checkUsePhone}</if>
            <if test="checkResult != null  and checkResult != ''"> and check_result = #{checkResult}</if>
            <if test="checkResultDetails != null  and checkResultDetails != ''"> and check_result_details = #{checkResultDetails}</if>
            <if test="checkResultPhoto != null  and checkResultPhoto != ''"> and check_result_photo = #{checkResultPhoto}</if>
            <if test="checkResultTime != null ">and  date_format(check_result_time,'%Y%m%d') = date_format(#{checkResultTime},'%Y%m%d')</if>
            <if test="createTime != null ">and  date_format(create_time,'%Y%m%d') = date_format(#{createTime},'%Y%m%d')</if>
            <if test="checkStatus != null  and checkStatus != ''"> and check_status = #{checkStatus}</if>
        </where>
    </select>
    
    <select id="selectCheckPointRecordByCheckPointRecordId" parameterType="Long" resultMap="CheckPointRecordResult">
        <include refid="selectCheckPointRecordVo"/>
        where check_point_record_id = #{checkPointRecordId}
    </select>

    <insert id="insertCheckPointRecord" parameterType="CheckPointRecord" useGeneratedKeys="true" keyProperty="checkPointRecordId">
        insert into check_point_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="checkPointManageId != null">check_point_manage_id,</if>
            <if test="dateTimeNum != null and dateTimeNum != ''">date_time_num,</if>
            <if test="checkType != null and checkType != ''">check_type,</if>
            <if test="checkTime != null">check_time,</if>
            <if test="checkAddress != null">check_address,</if>
            <if test="userName != null">user_name,</if>
            <if test="useId != null">use_id,</if>
            <if test="checkUserName != null">check_user_name,</if>
            <if test="checkUseId != null">check_use_id,</if>
            <if test="checkStaffId != null">check_staff_id,</if>
            <if test="checkUsePhone != null">check_use_phone,</if>
            <if test="checkResult != null">check_result,</if>
            <if test="checkResultDetails != null">check_result_details,</if>
            <if test="checkResultPhoto != null">check_result_photo,</if>
            <if test="checkResultTime != null">check_result_time,</if>
            <if test="checkStatus != null">check_status,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="checkPointManageId != null">#{checkPointManageId},</if>
            <if test="dateTimeNum != null and dateTimeNum != ''">#{dateTimeNum},</if>
            <if test="checkType != null and checkType != ''">#{checkType},</if>
            <if test="checkTime != null">#{checkTime},</if>
            <if test="checkAddress != null">#{checkAddress},</if>
            <if test="userName != null">#{userName},</if>
            <if test="useId != null">#{useId},</if>
            <if test="checkUserName != null">#{checkUserName},</if>
            <if test="checkUseId != null">#{checkUseId},</if>
            <if test="checkStaffId != null">#{checkStaffId},</if>
            <if test="checkUsePhone != null">#{checkUsePhone},</if>
            <if test="checkResult != null">#{checkResult},</if>
            <if test="checkResultDetails != null">#{checkResultDetails},</if>
            <if test="checkResultPhoto != null">#{checkResultPhoto},</if>
            <if test="checkResultTime != null">#{checkResultTime},</if>
            <if test="checkStatus != null">#{checkStatus},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateCheckPointRecord" parameterType="CheckPointRecord">
        update check_point_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="checkPointManageId != null">check_point_manage_id = #{checkPointManageId},</if>
            <if test="dateTimeNum != null and dateTimeNum != ''">date_time_num = #{dateTimeNum},</if>
            <if test="checkType != null and checkType != ''">check_type = #{checkType},</if>
            <if test="checkTime != null">check_time = #{checkTime},</if>
            <if test="checkAddress != null">check_address = #{checkAddress},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="useId != null">use_id = #{useId},</if>
            <if test="checkUserName != null">check_user_name = #{checkUserName},</if>
            <if test="checkUseId != null">check_use_id = #{checkUseId},</if>
            <if test="checkStaffId != null">check_staff_id = #{checkStaffId},</if>
            <if test="checkUsePhone != null">check_use_phone = #{checkUsePhone},</if>
            <if test="checkResult != null">check_result = #{checkResult},</if>
            <if test="checkResultDetails != null">check_result_details = #{checkResultDetails},</if>
            <if test="checkResultPhoto != null">check_result_photo = #{checkResultPhoto},</if>
            <if test="checkResultTime != null">check_result_time = #{checkResultTime},</if>
            <if test="checkStatus != null">check_status = #{checkStatus},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where check_point_record_id = #{checkPointRecordId}
    </update>

    <delete id="deleteCheckPointRecordByCheckPointRecordId" parameterType="Long">
        delete from check_point_record where check_point_record_id = #{checkPointRecordId}
    </delete>

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