<?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.zkqy.system.mapper.DragTableGroupMapper">

    <resultMap type="com.zkqy.system.entity.DragTableGroup" id="DragTableGroupResult">
        <result property="id"    column="id"    />
        <result property="groupName"    column="group_name"    />
        <result property="groupDescription"    column="group_description"    />
        <result property="groupTableInfo"    column="group_table_info"    />
        <result property="groupKey"    column="group_key"    />
        <result property="createById"    column="create_by_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateById"    column="update_by_id"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectDragTableGroupVo">
        select id, group_name, group_description,group_key, group_table_info,create_by_id, create_by, create_time, update_by_id, update_by, update_time from drag_table_group
    </sql>

    <select id="selectDragTableGroupList" parameterType="com.zkqy.system.entity.DragTableGroup" resultMap="DragTableGroupResult">
        <include refid="selectDragTableGroupVo"/>
        <where>
            <if test="groupName != null  and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
            <if test="groupDescription != null  and groupDescription != ''"> and group_description = #{groupDescription}</if>
            <if test="groupTableInfo != null  and groupTableInfo != ''"> and group_table_info = #{groupTableInfo}</if>
            <if test="groupType !=null  and groupType!=''">and group_type = #{groupType}</if>
<!--            <if test="createById != null   and createById != ''" > and create_by_id = #{createById}</if>-->
            <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<!--          <if test="updateById != null  and updateById != ''"> and update_by_id = #{updateById}</if>-->
        </where>
    </select>


    <select id="selectDragTableGroupByGroupKey" parameterType="String" resultType="string">
        select group_table_info from drag_table_group
        where group_key = #{groupKey}
    </select>

    <select id="selectDragTableGroupById" resultType="com.zkqy.system.entity.DragTableGroup" resultMap="DragTableGroupResult">
        <include refid="selectDragTableGroupVo"/>
        where  id=#{id}
    </select>

    <select id="selectDragTableGroupByIdIn" resultType="com.zkqy.system.entity.DragTableGroup">
        <include refid="selectDragTableGroupVo"/>
        where  id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>

    <select id="selectDragTableGroupOneByGroupKey" resultType="com.zkqy.system.entity.DragTableGroup" parameterType="string">
        <include refid="selectDragTableGroupVo"/>
        where  group_key=#{groupKey}
    </select>


    <insert id="insertDragTableGroup" parameterType="com.zkqy.system.entity.DragTableGroup">
        insert into drag_table_group
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="groupName != null">group_name,</if>
            <if test="groupKey!=null">group_key,</if>
            <if test="groupType!=null">group_type,</if>
            <if test="templateType!=null">template_type,</if>
            <if test="groupDescription != null">group_description,</if>
            <if test="groupTableInfo != null">group_table_info,</if>
            <if test="createById != null">create_by_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateById != null">update_by_id,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="groupName != null">#{groupName},</if>
            <if test="groupKey != null">#{groupKey},</if>
            <if test="groupType != null">#{groupType},</if>
            <if test="templateType!=null">#{templateType},</if>
            <if test="groupDescription != null">#{groupDescription},</if>
            <if test="groupTableInfo != null">#{groupTableInfo},</if>
            <if test="createById != null">#{createById},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateById != null">#{updateById},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateDragTableGroup" parameterType="com.zkqy.system.entity.DragTableGroup">
        update drag_table_group
        <trim prefix="SET" suffixOverrides=",">
            <if test="groupName != null">group_name = #{groupName},</if>
            <if test="groupDescription != null">group_description = #{groupDescription},</if>
            <if test="groupTableInfo != null">group_table_info = #{groupTableInfo},</if>
            <if test="templateType!=null">template_type =#{templateType},</if>
            <if test="createById != null">create_by_id = #{createById},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateById != null">update_by_id = #{updateById},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDragTableGroupById" parameterType="Long">
        delete from drag_table_group where id = #{id}
    </delete>

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

    <select id="selectDragTableGroupInfoByGroupKey" resultMap="DragTableGroupResult">
        <include refid="selectDragTableGroupVo"/>
        where group_key = #{groupKey}
    </select>

    <select id="selectDragTableGroupListCount" resultType="java.lang.Integer">
        select count(id) from {DBNAME}.drag_table_group
    </select>

</mapper>