<?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.zheng.cms.dao.mapper.CmsArticleTagMapper" >
  <resultMap id="BaseResultMap" type="com.zheng.cms.dao.model.CmsArticleTag" >
    <id column="article_tag_id" property="articleTagId" jdbcType="INTEGER" />
    <result column="article_id" property="articleId" jdbcType="INTEGER" />
    <result column="tag_id" property="tagId" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Example_Where_Clause" >
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" 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="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    article_tag_id, article_id, tag_id
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.zheng.cms.dao.model.CmsArticleTagExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from cms_article_tag
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
    <if test="limit != null" >
      <if test="offset != null" >
        limit ${offset}, ${limit}
      </if>
      <if test="offset == null" >
        limit ${limit}
      </if>
    </if>
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from cms_article_tag
    where article_tag_id = #{articleTagId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from cms_article_tag
    where article_tag_id = #{articleTagId,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.zheng.cms.dao.model.CmsArticleTagExample" >
    delete from cms_article_tag
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.zheng.cms.dao.model.CmsArticleTag" >
    insert into cms_article_tag (article_tag_id, article_id, tag_id
      )
    values (#{articleTagId,jdbcType=INTEGER}, #{articleId,jdbcType=INTEGER}, #{tagId,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.zheng.cms.dao.model.CmsArticleTag" >
    insert into cms_article_tag
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="articleTagId != null" >
        article_tag_id,
      </if>
      <if test="articleId != null" >
        article_id,
      </if>
      <if test="tagId != null" >
        tag_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="articleTagId != null" >
        #{articleTagId,jdbcType=INTEGER},
      </if>
      <if test="articleId != null" >
        #{articleId,jdbcType=INTEGER},
      </if>
      <if test="tagId != null" >
        #{tagId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.zheng.cms.dao.model.CmsArticleTagExample" resultType="java.lang.Integer" >
    select count(*) from cms_article_tag
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update cms_article_tag
    <set >
      <if test="record.articleTagId != null" >
        article_tag_id = #{record.articleTagId,jdbcType=INTEGER},
      </if>
      <if test="record.articleId != null" >
        article_id = #{record.articleId,jdbcType=INTEGER},
      </if>
      <if test="record.tagId != null" >
        tag_id = #{record.tagId,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update cms_article_tag
    set article_tag_id = #{record.articleTagId,jdbcType=INTEGER},
      article_id = #{record.articleId,jdbcType=INTEGER},
      tag_id = #{record.tagId,jdbcType=INTEGER}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.zheng.cms.dao.model.CmsArticleTag" >
    update cms_article_tag
    <set >
      <if test="articleId != null" >
        article_id = #{articleId,jdbcType=INTEGER},
      </if>
      <if test="tagId != null" >
        tag_id = #{tagId,jdbcType=INTEGER},
      </if>
    </set>
    where article_tag_id = #{articleTagId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.zheng.cms.dao.model.CmsArticleTag" >
    update cms_article_tag
    set article_id = #{articleId,jdbcType=INTEGER},
      tag_id = #{tagId,jdbcType=INTEGER}
    where article_tag_id = #{articleTagId,jdbcType=INTEGER}
  </update>
  <cache type="org.mybatis.caches.ehcache.LoggingEhcache" />
</mapper>