<?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.CheckPointManageMapper">
    
    <resultMap type="CheckPointManage" id="CheckPointManageResult">
        <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="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="selectCheckPointManageVo">
        select check_point_manage_id, date_time_num, check_type, check_time, check_address, user_name, use_id, create_by, create_time, update_by, update_time, remark from check_point_manage
    </sql>

    <select id="selectCheckPointManageList" parameterType="CheckPointManage" resultMap="CheckPointManageResult">
        <include refid="selectCheckPointManageVo"/>
        <where>  
            <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 check_time = #{checkTime}</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>
        </where>
        order by create_time DESC
    </select>
    
    <select id="selectCheckPointManageByCheckPointManageId" parameterType="Long" resultMap="CheckPointManageResult">
        <include refid="selectCheckPointManageVo"/>
        where check_point_manage_id = #{checkPointManageId}
    </select>

    <insert id="insertCheckPointManage" parameterType="CheckPointManage" useGeneratedKeys="true" keyProperty="checkPointManageId">
        insert into check_point_manage
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <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="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="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="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="updateCheckPointManage" parameterType="CheckPointManage">
        update check_point_manage
        <trim prefix="SET" suffixOverrides=",">
            <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="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_manage_id = #{checkPointManageId}
    </update>

    <insert id="batchCheckPointManage">
        insert into check_point_manage( check_type, check_time, check_address,create_time) values
        <foreach item="item" index="index" collection="list" separator=",">
            ( #{item.checkType}, #{item.checkTime}, #{item.checkAddress},#{item.createTime})
        </foreach>
    </insert>
    <delete id="deleteCheckPointManageByCheckPointManageId" parameterType="Long">
        delete from check_point_manage where check_point_manage_id = #{checkPointManageId}
    </delete>

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