<?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.CmsCategoryMapper" >
  <resultMap id="BaseResultMap" type="com.zheng.cms.dao.model.CmsCategory" >
    <id column="category_id" property="categoryId" jdbcType="INTEGER" />
    <result column="pid" property="pid" jdbcType="INTEGER" />
    <result column="level" property="level" jdbcType="TINYINT" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="description" property="description" jdbcType="VARCHAR" />
    <result column="icon" property="icon" jdbcType="VARCHAR" />
    <result column="type" property="type" jdbcType="TINYINT" />
    <result column="alias" property="alias" jdbcType="VARCHAR" />
    <result column="ctime" property="ctime" jdbcType="BIGINT" />
    <result column="orders" property="orders" jdbcType="BIGINT" />
  </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" >
    category_id, pid, level, name, description, icon, type, alias, ctime, orders
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.zheng.cms.dao.model.CmsCategoryExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from cms_category
    <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_category
    where category_id = #{categoryId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from cms_category
    where category_id = #{categoryId,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.zheng.cms.dao.model.CmsCategoryExample" >
    delete from cms_category
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.zheng.cms.dao.model.CmsCategory" >
    <selectKey resultType="java.lang.Integer" keyProperty="categoryId" order="AFTER" >
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into cms_category (pid, level, name, 
      description, icon, type, 
      alias, ctime, orders)
    values (#{pid,jdbcType=INTEGER}, #{level,jdbcType=TINYINT}, #{name,jdbcType=VARCHAR}, 
      #{description,jdbcType=VARCHAR}, #{icon,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT}, 
      #{alias,jdbcType=VARCHAR}, #{ctime,jdbcType=BIGINT}, #{orders,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" parameterType="com.zheng.cms.dao.model.CmsCategory" >
    <selectKey resultType="java.lang.Integer" keyProperty="categoryId" order="AFTER" >
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into cms_category
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="pid != null" >
        pid,
      </if>
      <if test="level != null" >
        level,
      </if>
      <if test="name != null" >
        name,
      </if>
      <if test="description != null" >
        description,
      </if>
      <if test="icon != null" >
        icon,
      </if>
      <if test="type != null" >
        type,
      </if>
      <if test="alias != null" >
        alias,
      </if>
      <if test="ctime != null" >
        ctime,
      </if>
      <if test="orders != null" >
        orders,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="pid != null" >
        #{pid,jdbcType=INTEGER},
      </if>
      <if test="level != null" >
        #{level,jdbcType=TINYINT},
      </if>
      <if test="name != null" >
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="description != null" >
        #{description,jdbcType=VARCHAR},
      </if>
      <if test="icon != null" >
        #{icon,jdbcType=VARCHAR},
      </if>
      <if test="type != null" >
        #{type,jdbcType=TINYINT},
      </if>
      <if test="alias != null" >
        #{alias,jdbcType=VARCHAR},
      </if>
      <if test="ctime != null" >
        #{ctime,jdbcType=BIGINT},
      </if>
      <if test="orders != null" >
        #{orders,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.zheng.cms.dao.model.CmsCategoryExample" resultType="java.lang.Integer" >
    select count(*) from cms_category
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update cms_category
    <set >
      <if test="record.categoryId != null" >
        category_id = #{record.categoryId,jdbcType=INTEGER},
      </if>
      <if test="record.pid != null" >
        pid = #{record.pid,jdbcType=INTEGER},
      </if>
      <if test="record.level != null" >
        level = #{record.level,jdbcType=TINYINT},
      </if>
      <if test="record.name != null" >
        name = #{record.name,jdbcType=VARCHAR},
      </if>
      <if test="record.description != null" >
        description = #{record.description,jdbcType=VARCHAR},
      </if>
      <if test="record.icon != null" >
        icon = #{record.icon,jdbcType=VARCHAR},
      </if>
      <if test="record.type != null" >
        type = #{record.type,jdbcType=TINYINT},
      </if>
      <if test="record.alias != null" >
        alias = #{record.alias,jdbcType=VARCHAR},
      </if>
      <if test="record.ctime != null" >
        ctime = #{record.ctime,jdbcType=BIGINT},
      </if>
      <if test="record.orders != null" >
        orders = #{record.orders,jdbcType=BIGINT},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update cms_category
    set category_id = #{record.categoryId,jdbcType=INTEGER},
      pid = #{record.pid,jdbcType=INTEGER},
      level = #{record.level,jdbcType=TINYINT},
      name = #{record.name,jdbcType=VARCHAR},
      description = #{record.description,jdbcType=VARCHAR},
      icon = #{record.icon,jdbcType=VARCHAR},
      type = #{record.type,jdbcType=TINYINT},
      alias = #{record.alias,jdbcType=VARCHAR},
      ctime = #{record.ctime,jdbcType=BIGINT},
      orders = #{record.orders,jdbcType=BIGINT}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.zheng.cms.dao.model.CmsCategory" >
    update cms_category
    <set >
      <if test="pid != null" >
        pid = #{pid,jdbcType=INTEGER},
      </if>
      <if test="level != null" >
        level = #{level,jdbcType=TINYINT},
      </if>
      <if test="name != null" >
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="description != null" >
        description = #{description,jdbcType=VARCHAR},
      </if>
      <if test="icon != null" >
        icon = #{icon,jdbcType=VARCHAR},
      </if>
      <if test="type != null" >
        type = #{type,jdbcType=TINYINT},
      </if>
      <if test="alias != null" >
        alias = #{alias,jdbcType=VARCHAR},
      </if>
      <if test="ctime != null" >
        ctime = #{ctime,jdbcType=BIGINT},
      </if>
      <if test="orders != null" >
        orders = #{orders,jdbcType=BIGINT},
      </if>
    </set>
    where category_id = #{categoryId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.zheng.cms.dao.model.CmsCategory" >
    update cms_category
    set pid = #{pid,jdbcType=INTEGER},
      level = #{level,jdbcType=TINYINT},
      name = #{name,jdbcType=VARCHAR},
      description = #{description,jdbcType=VARCHAR},
      icon = #{icon,jdbcType=VARCHAR},
      type = #{type,jdbcType=TINYINT},
      alias = #{alias,jdbcType=VARCHAR},
      ctime = #{ctime,jdbcType=BIGINT},
      orders = #{orders,jdbcType=BIGINT}
    where category_id = #{categoryId,jdbcType=INTEGER}
  </update>
  <cache type="org.mybatis.caches.ehcache.LoggingEhcache" />
</mapper>