<?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.ToBannerMapper" >
  <resultMap id="BaseResultMap" type="com.community.huiju.model.ToBanner" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="community_id" property="communityId" jdbcType="INTEGER" />
    <result column="title" property="title" jdbcType="VARCHAR" />
    <result column="banner_description" property="bannerDescription" jdbcType="VARCHAR" />
    <result column="sort" property="sort" jdbcType="INTEGER" />
    <result column="banner_cover" property="bannerCover" jdbcType="VARCHAR" />
    <result column="banner_position" property="bannerPosition" jdbcType="INTEGER" />
    <result column="eff_time" property="effTime" jdbcType="TIMESTAMP" />
    <result column="exp_time" property="expTime" jdbcType="TIMESTAMP" />
    <result column="banner_type" property="bannerType" jdbcType="CHAR" />
    <result column="external_link" property="externalLink" jdbcType="LONGVARCHAR" />
    <result column="banner_title" property="bannerTitle" jdbcType="VARCHAR" />
    <result column="create_user" property="createUser" jdbcType="INTEGER" />
    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
    <result column="update_user" property="updateUser" jdbcType="INTEGER" />
    <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
  </resultMap>
  <resultMap id="ResultMapWithBLOBs" type="com.community.huiju.model.ToBanner" extends="BaseResultMap" >
    <result column="banner_content" property="bannerContent" jdbcType="LONGVARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, community_id, title, banner_description, sort, banner_cover, banner_position,
    eff_time, exp_time, banner_type, external_link, banner_title, create_user, create_date,
    update_user, update_date
  </sql>
  <sql id="Blob_Column_List" >
    banner_content
  </sql>
  <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer" >
    select
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from to_banner
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from to_banner
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.community.huiju.model.ToBanner" >
    insert into to_banner (id, community_id, title,
      banner_description, sort, banner_cover,
      banner_position, eff_time, exp_time,
      banner_type, external_link, banner_title,
      create_user, create_date, update_user,
      update_date, banner_content)
    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR},
      #{bannerDescription,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, #{bannerCover,jdbcType=VARCHAR},
      #{bannerPosition,jdbcType=INTEGER}, #{effTime,jdbcType=TIMESTAMP}, #{expTime,jdbcType=TIMESTAMP},
      #{bannerType,jdbcType=CHAR}, #{externalLink,jdbcType=VARCHAR}, #{bannerTitle,jdbcType=VARCHAR},
      #{createUser,jdbcType=INTEGER}, #{createDate,jdbcType=TIMESTAMP}, #{updateUser,jdbcType=INTEGER},
      #{updateDate,jdbcType=TIMESTAMP}, #{bannerContent,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.community.huiju.model.ToBanner" >
    insert into to_banner
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="communityId != null" >
        community_id,
      </if>
      <if test="title != null" >
        title,
      </if>
      <if test="bannerDescription != null" >
        banner_description,
      </if>
      <if test="sort != null" >
        sort,
      </if>
      <if test="bannerCover != null" >
        banner_cover,
      </if>
      <if test="bannerPosition != null" >
        banner_position,
      </if>
      <if test="effTime != null" >
        eff_time,
      </if>
      <if test="expTime != null" >
        exp_time,
      </if>
      <if test="bannerType != null" >
        banner_type,
      </if>
      <if test="externalLink != null" >
        external_link,
      </if>
      <if test="bannerTitle != null" >
        banner_title,
      </if>
      <if test="createUser != null" >
        create_user,
      </if>
      <if test="createDate != null" >
        create_date,
      </if>
      <if test="updateUser != null" >
        update_user,
      </if>
      <if test="updateDate != null" >
        update_date,
      </if>
      <if test="bannerContent != null" >
        banner_content,
      </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="title != null" >
        #{title,jdbcType=VARCHAR},
      </if>
      <if test="bannerDescription != null" >
        #{bannerDescription,jdbcType=VARCHAR},
      </if>
      <if test="sort != null" >
        #{sort,jdbcType=INTEGER},
      </if>
      <if test="bannerCover != null" >
        #{bannerCover,jdbcType=VARCHAR},
      </if>
      <if test="bannerPosition != null" >
        #{bannerPosition,jdbcType=INTEGER},
      </if>
      <if test="effTime != null" >
        #{effTime,jdbcType=TIMESTAMP},
      </if>
      <if test="expTime != null" >
        #{expTime,jdbcType=TIMESTAMP},
      </if>
      <if test="bannerType != null" >
        #{bannerType,jdbcType=CHAR},
      </if>
      <if test="externalLink != null" >
        #{externalLink,jdbcType=VARCHAR},
      </if>
      <if test="bannerTitle != null" >
        #{bannerTitle,jdbcType=VARCHAR},
      </if>
      <if test="createUser != null" >
        #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null" >
        #{updateUser,jdbcType=INTEGER},
      </if>
      <if test="updateDate != null" >
        #{updateDate,jdbcType=TIMESTAMP},
      </if>
      <if test="bannerContent != null" >
        #{bannerContent,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.ToBanner" >
    update to_banner
    <set >
      <if test="communityId != null" >
        community_id = #{communityId,jdbcType=INTEGER},
      </if>
      <if test="title != null" >
        title = #{title,jdbcType=VARCHAR},
      </if>
      <if test="bannerDescription != null" >
        banner_description = #{bannerDescription,jdbcType=VARCHAR},
      </if>
      <if test="sort != null" >
        sort = #{sort,jdbcType=INTEGER},
      </if>
      <if test="bannerCover != null" >
        banner_cover = #{bannerCover,jdbcType=VARCHAR},
      </if>
      <if test="bannerPosition != null" >
        banner_position = #{bannerPosition,jdbcType=INTEGER},
      </if>
      <if test="effTime != null" >
        eff_time = #{effTime,jdbcType=TIMESTAMP},
      </if>
      <if test="expTime != null" >
        exp_time = #{expTime,jdbcType=TIMESTAMP},
      </if>
      <if test="bannerType != null" >
        banner_type = #{bannerType,jdbcType=CHAR},
      </if>
      <if test="externalLink != null" >
        external_link = #{externalLink,jdbcType=VARCHAR},
      </if>
      <if test="bannerTitle != null" >
        banner_title = #{bannerTitle,jdbcType=VARCHAR},
      </if>
      <if test="createUser != null" >
        create_user = #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createDate != null" >
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null" >
        update_user = #{updateUser,jdbcType=INTEGER},
      </if>
      <if test="updateDate != null" >
        update_date = #{updateDate,jdbcType=TIMESTAMP},
      </if>
      <if test="bannerContent != null" >
        banner_content = #{bannerContent,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.community.huiju.model.ToBanner" >
    update to_banner
    set community_id = #{communityId,jdbcType=INTEGER},
      title = #{title,jdbcType=VARCHAR},
      banner_description = #{bannerDescription,jdbcType=VARCHAR},
      sort = #{sort,jdbcType=INTEGER},
      banner_cover = #{bannerCover,jdbcType=VARCHAR},
      banner_position = #{bannerPosition,jdbcType=INTEGER},
      eff_time = #{effTime,jdbcType=TIMESTAMP},
      exp_time = #{expTime,jdbcType=TIMESTAMP},
      banner_type = #{bannerType,jdbcType=CHAR},
      external_link = #{externalLink,jdbcType=VARCHAR},
      banner_title = #{bannerTitle,jdbcType=VARCHAR},
      create_user = #{createUser,jdbcType=INTEGER},
      create_date = #{createDate,jdbcType=TIMESTAMP},
      update_user = #{updateUser,jdbcType=INTEGER},
      update_date = #{updateDate,jdbcType=TIMESTAMP},
      banner_content = #{bannerContent,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.ToBanner" >
    update to_banner
    set community_id = #{communityId,jdbcType=INTEGER},
      title = #{title,jdbcType=VARCHAR},
      banner_description = #{bannerDescription,jdbcType=VARCHAR},
      sort = #{sort,jdbcType=INTEGER},
      banner_cover = #{bannerCover,jdbcType=VARCHAR},
      banner_position = #{bannerPosition,jdbcType=INTEGER},
      eff_time = #{effTime,jdbcType=TIMESTAMP},
      exp_time = #{expTime,jdbcType=TIMESTAMP},
      banner_type = #{bannerType,jdbcType=CHAR},
      external_link = #{externalLink,jdbcType=VARCHAR},
      banner_title = #{bannerTitle,jdbcType=VARCHAR},
      create_user = #{createUser,jdbcType=INTEGER},
      create_date = #{createDate,jdbcType=TIMESTAMP},
      update_user = #{updateUser,jdbcType=INTEGER},
      update_date = #{updateDate,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="selectBanner" parameterType="com.community.huiju.model.ToBanner" resultMap="BaseResultMap" >
    select
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from to_banner
    <trim prefix="where" prefixOverrides="and">
      <if test="title != null and title !=''">
       and title like concat('%',#{title,jdbcType=VARCHAR},'%')
      </if>
      <if test="bannerDescription != null and bannerDescription != ''">
       and banner_description like concat('%',#{bannerDescription,jdbcType=VARCHAR},'%')
      </if>
      <if test="bannerPosition != null and bannerPosition != ''">
       and banner_position = #{bannerPosition,jdbcType=INTEGER}
      </if>
      <if test="communityId != null">
       and community_id = #{communityId,jdbcType=INTEGER}
      </if>
    </trim>
    order by create_date DESC
  </select>

  <delete id="deleteBanchBanner" parameterType="list">
    delete from to_banner
    where id in
    <foreach collection="list" item="item" separator="," index="index" open="(" close=")">
      #{item,jdbcType=INTEGER}
    </foreach>
  </delete>
</mapper>