<?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.xinelu.manage.mapper.wechattemplatesuittask.WechatTemplateSuitTaskMapper">

    <resultMap type="WechatTemplateSuitTask" id="WechatTemplateSuitTaskResult">
            <result property="id" column="id"/>
            <result property="wechatTemplateId" column="wechat_template_id"/>
            <result property="suitTaskTypeId" column="suit_task_type_id"/>
            <result property="suitTaskTypeName" column="suit_task_type_name"/>
            <result property="createBy" column="create_by"/>
            <result property="createTime" column="create_time"/>
            <result property="updateBy" column="update_by"/>
            <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectWechatTemplateSuitTaskVo">
        select id, wechat_template_id, suit_task_type_id, suit_task_type_name, create_by, create_time, update_by, update_time from wechat_template_suit_task
    </sql>

    <select id="selectWechatTemplateSuitTaskList" parameterType="WechatTemplateSuitTask" resultMap="WechatTemplateSuitTaskResult">
        <include refid="selectWechatTemplateSuitTaskVo"/>
        <where>
                        <if test="wechatTemplateId != null ">
                            and wechat_template_id = #{wechatTemplateId}
                        </if>
                        <if test="suitTaskTypeName != null  and suitTaskTypeName != ''">
                            and suit_task_type_name like concat('%', #{suitTaskTypeName}, '%')
                        </if>
        </where>
    </select>

    <select id="selectWechatTemplateSuitTaskById" parameterType="Long"
            resultMap="WechatTemplateSuitTaskResult">
            <include refid="selectWechatTemplateSuitTaskVo"/>
            where id = #{id}
    </select>

    <insert id="insertWechatTemplateSuitTask" parameterType="WechatTemplateSuitTask" useGeneratedKeys="true"
            keyProperty="id">
        insert into wechat_template_suit_task
        <trim prefix="(" suffix=")" suffixOverrides=",">
                    <if test="wechatTemplateId != null">wechat_template_id,
                    </if>
                    <if test="suitTaskTypeId != null">suit_task_type_id,
                    </if>
                    <if test="suitTaskTypeName != null">suit_task_type_name,
                    </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>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                    <if test="wechatTemplateId != null">#{wechatTemplateId},
                    </if>
                    <if test="suitTaskTypeId != null">#{suitTaskTypeId},
                    </if>
                    <if test="suitTaskTypeName != null">#{suitTaskTypeName},
                    </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>
        </trim>
    </insert>

    <update id="updateWechatTemplateSuitTask" parameterType="WechatTemplateSuitTask">
        update wechat_template_suit_task
        <trim prefix="SET" suffixOverrides=",">
                    <if test="wechatTemplateId != null">wechat_template_id =
                        #{wechatTemplateId},
                    </if>
                    <if test="suitTaskTypeId != null">suit_task_type_id =
                        #{suitTaskTypeId},
                    </if>
                    <if test="suitTaskTypeName != null">suit_task_type_name =
                        #{suitTaskTypeName},
                    </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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWechatTemplateSuitTaskById" parameterType="Long">
        delete from wechat_template_suit_task where id = #{id}
    </delete>

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