<?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.community.huiju.dao.TpCarouselSettingMapper" >
  <resultMap id="BaseResultMap" type="com.community.huiju.model.TpCarouselSetting" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="community_id" property="communityId" jdbcType="INTEGER" />
    <result column="carousel_type" property="carouselType" jdbcType="VARCHAR" />
    <result column="carousel_num" property="carouselNum" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, community_id, carousel_type, carousel_num
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from tp_carousel_setting
    where id = #{id,jdbcType=INTEGER}
  </select>
  <select id="selectCarouselNum" resultType="java.lang.Integer" parameterType="java.lang.String" >
    select
    carousel_num
    from tp_carousel_setting
    where carousel_type = #{carouselType}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from tp_carousel_setting
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.community.huiju.model.TpCarouselSetting" >
    insert into tp_carousel_setting (id, community_id, carousel_type, 
      carousel_num)
    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{carouselType,jdbcType=VARCHAR}, 
      #{carouselNum,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.community.huiju.model.TpCarouselSetting" >
    insert into tp_carousel_setting
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="communityId != null" >
        community_id,
      </if>
      <if test="carouselType != null" >
        carousel_type,
      </if>
      <if test="carouselNum != null" >
        carousel_num,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="communityId != null" >
        #{communityId,jdbcType=INTEGER},
      </if>
      <if test="carouselType != null" >
        #{carouselType,jdbcType=VARCHAR},
      </if>
      <if test="carouselNum != null" >
        #{carouselNum,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TpCarouselSetting" >
    update tp_carousel_setting
    <set >
      <if test="communityId != null" >
        community_id = #{communityId,jdbcType=INTEGER},
      </if>
      <if test="carouselType != null" >
        carousel_type = #{carouselType,jdbcType=VARCHAR},
      </if>
      <if test="carouselNum != null" >
        carousel_num = #{carouselNum,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TpCarouselSetting" >
    update tp_carousel_setting
    set community_id = #{communityId,jdbcType=INTEGER},
      carousel_type = #{carouselType,jdbcType=VARCHAR},
      carousel_num = #{carouselNum,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <select id="getcarouselNum"  resultType="java.lang.Integer">
    select carousel_num
    from
    tp_carousel_setting
    where  carousel_type=#{lease,jdbcType=VARCHAR}
    and community_id = #{communityId,jdbcType=INTEGER}
  </select>


</mapper>