<?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.ArticleMapper">
  <resultMap id="BaseResultMap" type="lingtao.net.bean.Article">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="title" jdbcType="VARCHAR" property="title" />
    <result column="type" jdbcType="VARCHAR" property="type" />
    <result column="status" jdbcType="VARCHAR" property="status" />
    <result column="imagesUrl" jdbcType="VARCHAR" property="imagesUrl" />
    <result column="hit" jdbcType="INTEGER" property="hit" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="createBy" jdbcType="VARCHAR" property="createBy" />
    <result column="createDate" jdbcType="TIMESTAMP" property="createDate" />
    <result column="updateBy" jdbcType="VARCHAR" property="updateBy" />
    <result column="updateDate" jdbcType="TIMESTAMP" property="updateDate" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="lingtao.net.bean.Article">
    <result column="content" jdbcType="LONGVARCHAR" property="content" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, title, type, status, imagesUrl, hit, remark, createBy, createDate, updateBy, 
    updateDate
  </sql>
  <sql id="Blob_Column_List">
    content
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="lingtao.net.bean.ArticleExample" resultMap="ResultMapWithBLOBs">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from tbl_article
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByExample" parameterType="lingtao.net.bean.ArticleExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from tbl_article
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="ResultMapWithBLOBs">
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from tbl_article
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from tbl_article
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="lingtao.net.bean.ArticleExample">
    delete from tbl_article
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="lingtao.net.bean.Article">
    insert into tbl_article (id, title, type, 
      status, imagesUrl, hit, 
      remark, createBy, createDate, 
      updateBy, updateDate, content
      )
    values (#{id,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, 
      #{status,jdbcType=VARCHAR}, #{imagesUrl,jdbcType=VARCHAR}, #{hit,jdbcType=INTEGER}, 
      #{remark,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, 
      #{updateBy,jdbcType=VARCHAR}, #{updateDate,jdbcType=TIMESTAMP}, #{content,jdbcType=LONGVARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="lingtao.net.bean.Article">
    insert into tbl_article
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="title != null">
        title,
      </if>
      <if test="type != null">
        type,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="imagesUrl != null">
        imagesUrl,
      </if>
      <if test="hit != null">
        hit,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="createBy != null">
        createBy,
      </if>
      <if test="createDate != null">
        createDate,
      </if>
      <if test="updateBy != null">
        updateBy,
      </if>
      <if test="updateDate != null">
        updateDate,
      </if>
      <if test="content != null">
        content,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="title != null">
        #{title,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        #{type,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="imagesUrl != null">
        #{imagesUrl,jdbcType=VARCHAR},
      </if>
      <if test="hit != null">
        #{hit,jdbcType=INTEGER},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null">
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateDate != null">
        #{updateDate,jdbcType=TIMESTAMP},
      </if>
      <if test="content != null">
        #{content,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="lingtao.net.bean.ArticleExample" resultType="java.lang.Long">
    select count(*) from tbl_article
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update tbl_article
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.title != null">
        title = #{record.title,jdbcType=VARCHAR},
      </if>
      <if test="record.type != null">
        type = #{record.type,jdbcType=VARCHAR},
      </if>
      <if test="record.status != null">
        status = #{record.status,jdbcType=VARCHAR},
      </if>
      <if test="record.imagesUrl != null">
        imagesUrl = #{record.imagesUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.hit != null">
        hit = #{record.hit,jdbcType=INTEGER},
      </if>
      <if test="record.remark != null">
        remark = #{record.remark,jdbcType=VARCHAR},
      </if>
      <if test="record.createBy != null">
        createBy = #{record.createBy,jdbcType=VARCHAR},
      </if>
      <if test="record.createDate != null">
        createDate = #{record.createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updateBy != null">
        updateBy = #{record.updateBy,jdbcType=VARCHAR},
      </if>
      <if test="record.updateDate != null">
        updateDate = #{record.updateDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.content != null">
        content = #{record.content,jdbcType=LONGVARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map">
    update tbl_article
    set id = #{record.id,jdbcType=INTEGER},
      title = #{record.title,jdbcType=VARCHAR},
      type = #{record.type,jdbcType=VARCHAR},
      status = #{record.status,jdbcType=VARCHAR},
      imagesUrl = #{record.imagesUrl,jdbcType=VARCHAR},
      hit = #{record.hit,jdbcType=INTEGER},
      remark = #{record.remark,jdbcType=VARCHAR},
      createBy = #{record.createBy,jdbcType=VARCHAR},
      createDate = #{record.createDate,jdbcType=TIMESTAMP},
      updateBy = #{record.updateBy,jdbcType=VARCHAR},
      updateDate = #{record.updateDate,jdbcType=TIMESTAMP},
      content = #{record.content,jdbcType=LONGVARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update tbl_article
    set id = #{record.id,jdbcType=INTEGER},
      title = #{record.title,jdbcType=VARCHAR},
      type = #{record.type,jdbcType=VARCHAR},
      status = #{record.status,jdbcType=VARCHAR},
      imagesUrl = #{record.imagesUrl,jdbcType=VARCHAR},
      hit = #{record.hit,jdbcType=INTEGER},
      remark = #{record.remark,jdbcType=VARCHAR},
      createBy = #{record.createBy,jdbcType=VARCHAR},
      createDate = #{record.createDate,jdbcType=TIMESTAMP},
      updateBy = #{record.updateBy,jdbcType=VARCHAR},
      updateDate = #{record.updateDate,jdbcType=TIMESTAMP}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="lingtao.net.bean.Article">
    update tbl_article
    <set>
      <if test="title != null">
        title = #{title,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        type = #{type,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=VARCHAR},
      </if>
      <if test="imagesUrl != null">
        imagesUrl = #{imagesUrl,jdbcType=VARCHAR},
      </if>
      <if test="hit != null">
        hit = #{hit,jdbcType=INTEGER},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        createBy = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null">
        createDate = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        updateBy = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateDate != null">
        updateDate = #{updateDate,jdbcType=TIMESTAMP},
      </if>
      <if test="content != null">
        content = #{content,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="lingtao.net.bean.Article">
    update tbl_article
    set title = #{title,jdbcType=VARCHAR},
      type = #{type,jdbcType=VARCHAR},
      status = #{status,jdbcType=VARCHAR},
      imagesUrl = #{imagesUrl,jdbcType=VARCHAR},
      hit = #{hit,jdbcType=INTEGER},
      remark = #{remark,jdbcType=VARCHAR},
      createBy = #{createBy,jdbcType=VARCHAR},
      createDate = #{createDate,jdbcType=TIMESTAMP},
      updateBy = #{updateBy,jdbcType=VARCHAR},
      updateDate = #{updateDate,jdbcType=TIMESTAMP},
      content = #{content,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="lingtao.net.bean.Article">
    update tbl_article
    set title = #{title,jdbcType=VARCHAR},
      type = #{type,jdbcType=VARCHAR},
      status = #{status,jdbcType=VARCHAR},
      imagesUrl = #{imagesUrl,jdbcType=VARCHAR},
      hit = #{hit,jdbcType=INTEGER},
      remark = #{remark,jdbcType=VARCHAR},
      createBy = #{createBy,jdbcType=VARCHAR},
      createDate = #{createDate,jdbcType=TIMESTAMP},
      updateBy = #{updateBy,jdbcType=VARCHAR},
      updateDate = #{updateDate,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <select id="getArticle" parameterType="Article" resultMap="BaseResultMap">
  		select * from tbl_article
  		<where>
  			<if test="title != null and title != ''">
  				title like '%${title}%'
  			</if>
  			<if test="type != null and type != ''">
  				type = #{type}
  			</if>
  		</where>
  		ORDER BY createDate DESC
  </select>
</mapper>