<?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.ematou.wxservice.mapper.SubscribeItemMapper">

    <sql id="Base_Column_List">
        wechat_account,
        title,
        description,
        pic_url,
        url,
        creator_id,
        create_time,
        moder_id,
        mod_time
    </sql>

    <insert id="insertSubscribeItem" >
        insert into mp_subscribe_item ( <include refid="Base_Column_List"/> )
        values (#{subscribeItem.wechatAccount},
                #{subscribeItem.title},
                #{subscribeItem.description},
                #{subscribeItem.picUrl},
                #{subscribeItem.url},
                #{subscribeItem.creatorId},
                #{subscribeItem.createTime},
                #{subscribeItem.moderId},
                #{subscribeItem.modTime}
        )
    </insert>


    <update id="updateSubscribeItem">
        update mp_subscribe_item
        <set>
            <if test="subscribeItem.wechatAccount != null">
                wechat_account=#{subscribeItem.wechatAccount},
            </if>
            <if test="subscribeItem.title != null">
                title=#{subscribeItem.title},
            </if>
            <if test="subscribeItem.description != null">
                description=#{subscribeItem.description},
            </if>
            <if test="subscribeItem.picUrl != null">
                pic_url=#{subscribeItem.picUrl},
            </if>
            <if test="subscribeItem.url != null">
                url=#{subscribeItem.url},
            </if>
            <if test="subscribeItem.moderId != null">
                moder_id=#{subscribeItem.moderId},
            </if>
            <if test="subscribeItem.modTime != null">
                mod_time=#{subscribeItem.modTime},
            </if>
            <if test="subscribeItem.tmst != null">
                tmst=#{subscribeItem.tmst},
            </if>
        </set>
        <if test="subscribeItem.id">
            where id=#{subscribeItem.id}
        </if>
    </update>

    <select id="queryByWechatAccount" resultType="com.ematou.wxservice.entity.pojo.SubscribeItem">
        select <include refid="Base_Column_List"/>
            from mp_subscribe_item
        where wechat_account=#{wechatAccount}
    </select>


    <delete id="deleteByWechatAccount" >
        delete from mp_subscribe_item
        where wechat_account=#{wechatAccount}
    </delete>

</mapper>
