<?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.fs.company.mapper.CompanyWxDialogMapper">
    
    <resultMap type="CompanyWxDialog" id="CompanyWxDialogResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="templateDetails"    column="template_details"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectCompanyWxDialogVo">
        select * from company_wx_dialog
    </sql>

    <select id="selectCompanyWxDialogList" parameterType="CompanyWxDialog" resultMap="CompanyWxDialogResult">
        <include refid="selectCompanyWxDialogVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="templateDetails != null  and templateDetails != ''"> and template_details = #{templateDetails}</if>
        </where>
    </select>
    
    <select id="selectCompanyWxDialogById" parameterType="Long" resultMap="CompanyWxDialogResult">
        <include refid="selectCompanyWxDialogVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCompanyWxDialog" parameterType="CompanyWxDialog" useGeneratedKeys="true" keyProperty="id">
        insert into company_wx_dialog
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="templateDetails != null">template_details,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createUser != null">create_user,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="templateDetails != null">#{templateDetails},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createUser != null">#{createUser},</if>
         </trim>
    </insert>

    <update id="updateCompanyWxDialog" parameterType="CompanyWxDialog">
        update company_wx_dialog
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="templateDetails != null">template_details = #{templateDetails},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCompanyWxDialogById" parameterType="Long">
        delete from company_wx_dialog where id = #{id}
    </delete>

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