<?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.kaohe.mapper.KhGatherMapper">
    
    <resultMap type="KhGather" id="KhGatherResult">
        <result property="id"    column="id"    />
        <result property="hzName"    column="hz_name"    />
        <result property="tableHeader"    column="table_header"    />
        <result property="tableData"    column="table_data"    />
        <result property="titleStr"    column="title_str"    />
        <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="selectKhGatherVo">
        select id, hz_name, table_header, table_data,title_str, create_by, create_time, update_by, update_time, remark from kh_gather
    </sql>

    <select id="selectKhGatherList" parameterType="KhGather" resultMap="KhGatherResult">
        <include refid="selectKhGatherVo"/>
        <where>  
            <if test="hzName != null  and hzName != ''"> and hz_name like concat('%', #{hzName}, '%')</if>
            <!--<if test="tableHeader != null  and tableHeader != ''"> and table_header = #{tableHeader}</if>
            <if test="tableData != null  and tableData != ''"> and table_data = #{tableData}</if>-->
            <if test="titleStr != null  and titleStr != ''"> and title_str = #{titleStr}</if>
        </where>
        ORDER BY id DESC
    </select>
    
    <select id="selectKhGatherById" parameterType="Long" resultMap="KhGatherResult">
        <include refid="selectKhGatherVo"/>
        where id = #{id}
    </select>

    <insert id="insertKhGather" parameterType="KhGather" useGeneratedKeys="true" keyProperty="id">
        insert into kh_gather
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="hzName != null">hz_name,</if>
            <if test="tableHeader != null">table_header,</if>
            <if test="tableData != null">table_data,</if>
            <if test="titleStr != null">title_str,</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="hzName != null">#{hzName},</if>
            <if test="tableHeader != null">#{tableHeader},</if>
            <if test="tableData != null">#{tableData},</if>
            <if test="titleStr != null">#{titleStr},</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="updateKhGather" parameterType="KhGather">
        update kh_gather
        <trim prefix="SET" suffixOverrides=",">
            <if test="hzName != null">hz_name = #{hzName},</if>
            <if test="tableHeader != null">table_header = #{tableHeader},</if>
            <if test="tableData != null">table_data = #{tableData},</if>
            <if test="titleStr != null">title_str = #{titleStr},</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 id = #{id}
    </update>

    <delete id="deleteKhGatherById" parameterType="Long">
        delete from kh_gather where id = #{id}
    </delete>

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