<?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="lingtao.net.dao.TipContentMapper">
    <select id="getTipContents" parameterType="lingtao.net.bean.TipContent"
            resultType="lingtao.net.bean.TipContent">
        SELECT
        *
        FROM
        tbl_tip_content
        <where>
            <if test="content != null and content != ''">
                title like '%${content}%' or content like '%${content}%'
            </if>
        </where>
        order by id desc
    </select>

    <insert id="addTipContent" parameterType="lingtao.net.bean.TipContent">
        insert into tbl_tip_content
            (content, createBy, createDate, title,attachment,type)
        values (#{content}, #{createBy}, now(), #{title}, #{attachment}, #{type})
    </insert>

    <update id="updateTipContentById" parameterType="lingtao.net.bean.TipContent">
        update tbl_tip_content
        <set>
            <if test="content != null">
                content = #{content,jdbcType=VARCHAR},
            </if>
            <if test="updateBy != null">
                updateBy = #{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="updateDate != null">
                updateDate = now(),
            </if>
            <if test="title != null">
                title = #{title,jdbcType=VARCHAR},
            </if>
            <if test="attachment != null">
                attachment = #{attachment,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>

    <delete id="deleteTipContentById">
        delete
        from tbl_tip_content
        where id = #{id}
    </delete>
</mapper>