<?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.cab.dao.ContentTypeMapper" >
  <resultMap id="BaseResultMap" type="com.cab.model.ContentType" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="level" property="level" jdbcType="INTEGER" />
    <result column="parent_type_id" property="parentTypeId" jdbcType="VARCHAR" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="imgurl" property="imgUrl" jdbcType="VARCHAR"/>
    <result column="can_into" property="canInto" jdbcType="INTEGER" />
    <result column="push_count" property="pushCount" jdbcType="INTEGER" />
    <result column="display_mode" property="displayMode" jdbcType="INTEGER" />
  </resultMap>
  
  <resultMap id="BaseJoinMap" type="com.cab.model.ContentType" >
    <id column="content_type_id" property="id" jdbcType="VARCHAR" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="can_into" property="canInto" jdbcType="INTEGER" />
    <result column="display_mode" property="displayMode" jdbcType="INTEGER" />
  </resultMap>
  
  <sql id="Base_Column_List" >
    id, level, parent_type_id, name,imgurl, can_into, push_count, display_mode
  </sql>
  <select id="selectByParentIdList" resultMap="BaseResultMap" >
    select 
    <include refid="Base_Column_List" />
    from cab_content_type
    where parent_type_id in 
    <foreach item="item" index="index" collection="list" open="(" separator="," close=")">#{item}</foreach>
  </select>
  <select id="selectAll" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from cab_content_type
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from cab_content_type
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from cab_content_type
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.cab.model.ContentType" >
    insert into cab_content_type (id, level, parent_type_id, 
      name,imgurl, can_into, push_count,
      display_mode)
    values (#{id,jdbcType=VARCHAR}, #{level,jdbcType=INTEGER}, #{parentTypeId,jdbcType=VARCHAR}, 
      #{name,jdbcType=VARCHAR},#{imgUrl,jdbcType=VARCHAR}, #{canInto,jdbcType=INTEGER}, #{pushCount,jdbcType=INTEGER},
      #{displayMode,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.cab.model.ContentType" >
    insert into cab_content_type
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="level != null" >
        level,
      </if>
      <if test="parentTypeId != null" >
        parent_type_id,
      </if>
      <if test="name != null" >
        name,
      </if>
      <if test="imgUrl != null" >
        imgurl,
      </if>
      <if test="canInto != null" >
        can_into,
      </if>
      <if test="pushCount != null" >
        push_count,
      </if>
      <if test="displayMode != null" >
        display_mode,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="level != null" >
        #{level,jdbcType=INTEGER},
      </if>
      <if test="parentTypeId != null" >
        #{parentTypeId,jdbcType=VARCHAR},
      </if>
      <if test="name != null" >
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="imgUrl != null" >
        #{imgUrl,jdbcType=VARCHAR},
      </if>
      <if test="canInto != null" >
        #{canInto,jdbcType=INTEGER},
      </if>
      <if test="pushCount != null" >
        #{pushCount,jdbcType=INTEGER},
      </if>
      <if test="displayMode != null" >
        #{displayMode,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.cab.model.ContentType" >
    update cab_content_type
    <set >
      <if test="level != null" >
        level = #{level,jdbcType=INTEGER},
      </if>
      <if test="parentTypeId != null" >
        parent_type_id = #{parentTypeId,jdbcType=VARCHAR},
      </if>
      <if test="name != null" >
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="imgUrl != null" >
        imgurl = #{imgUrl,jdbcType=VARCHAR},
      </if>
      <if test="canInto != null" >
        can_into = #{canInto,jdbcType=INTEGER},
      </if>
      <if test="pushCount != null" >
        push_count = #{pushCount,jdbcType=INTEGER},
      </if>
      <if test="displayMode != null" >
        display_mode = #{displayMode,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.cab.model.ContentType" >
    update cab_content_type
    set level = #{level,jdbcType=INTEGER},
      parent_type_id = #{parentTypeId,jdbcType=VARCHAR},
      name = #{name,jdbcType=VARCHAR},
      can_into = #{canInto,jdbcType=INTEGER},
      push_count = #{pushCount,jdbcType=INTEGER},
      display_mode = #{displayMode,jdbcType=INTEGER}
    where id = #{id,jdbcType=VARCHAR}
  </update>
<!--********************************************************* 自定义********************************************* -->
  <select id="getIsFirst" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from cab_content_type 
    where parent_type_id= #{paramsType,jdbcType=VARCHAR}
  </select>
</mapper>