<?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.tongran.rocketmq.mapper.AllMoudleNameMapper">
    
    <resultMap type="AllMoudleName" id="AllMoudleNameResult">
        <result property="id"    column="id"    />
        <result property="clientId"    column="client_id"    />
        <result property="name"    column="name"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectAllMoudleNameVo">
        select id, client_id, name, create_time, update_time from all_moudle_name
    </sql>

    <select id="selectAllMoudleNameList" parameterType="AllMoudleName" resultMap="AllMoudleNameResult">
        <include refid="selectAllMoudleNameVo"/>
        <where>  
            <if test="clientId != null  and clientId != ''"> and client_id = #{clientId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
        </where>
    </select>
    
    <select id="selectAllMoudleNameById" parameterType="Long" resultMap="AllMoudleNameResult">
        <include refid="selectAllMoudleNameVo"/>
        where id = #{id}
    </select>

    <insert id="insertAllMoudleName" parameterType="AllMoudleName" useGeneratedKeys="true" keyProperty="id">
        insert into all_moudle_name
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="clientId != null and clientId != ''">client_id,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="clientId != null and clientId != ''">#{clientId},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateAllMoudleName" parameterType="AllMoudleName">
        update all_moudle_name
        <trim prefix="SET" suffixOverrides=",">
            <if test="clientId != null and clientId != ''">client_id = #{clientId},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAllMoudleNameById" parameterType="Long">
        delete from all_moudle_name where id = #{id}
    </delete>

    <delete id="deleteAllMoudleNameByIds" parameterType="String">
        delete from all_moudle_name where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <insert id="batchInsertMoudleName" parameterType="java.util.List">
        insert IGNORE into all_moudle_name
        (client_id, name, create_time, update_time)
        values
        <foreach collection="list" item="item" separator=",">
            (
            #{item.clientId},
            #{item.name},
            #{item.createTime},
            #{item.updateTime}
            )
        </foreach>
    </insert>
</mapper>