<?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.flossom.common.core.mapper.ActivityChannelInfoMapper">

    <resultMap type="ActivityChannelInfo" id="ActivityChannelInfoResult">
        <result property="id"    column="id"    />
        <result property="channelType"    column="channel_type"    />
        <result property="channelName"    column="channel_name"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
    </resultMap>

    <sql id="selectActivityChannelInfoVo">
        select id, channel_type, channel_name, create_time, create_by from activity_channel_info
    </sql>

    <select id="selectActivityChannelInfoList" parameterType="ActivityChannelInfo" resultMap="ActivityChannelInfoResult">
        <include refid="selectActivityChannelInfoVo"/>
        <where>
            <if test="channelType != null "> and channel_type = #{channelType}</if>
            <if test="channelName != null  and channelName != ''"> and channel_name like concat('%', #{channelName}, '%')</if>
        </where>
    </select>

    <select id="selectActivityChannelInfoById" parameterType="Long" resultMap="ActivityChannelInfoResult">
        <include refid="selectActivityChannelInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertActivityChannelInfo" parameterType="ActivityChannelInfo">
        insert into activity_channel_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="channelType != null">channel_type,</if>
            <if test="channelName != null">channel_name,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="channelType != null">#{channelType},</if>
            <if test="channelName != null">#{channelName},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
         </trim>
    </insert>

    <update id="updateActivityChannelInfo" parameterType="ActivityChannelInfo">
        update activity_channel_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="channelType != null">channel_type = #{channelType},</if>
            <if test="channelName != null">channel_name = #{channelName},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteActivityChannelInfoById" parameterType="Long">
        delete from activity_channel_info where id = #{id}
    </delete>

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