<?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.goafanti.common.dao.BannersMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.Banners">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="sign" jdbcType="VARCHAR" property="sign" />
    <result column="text" jdbcType="VARCHAR" property="text" />
    <result column="imgUrl" jdbcType="VARCHAR" property="imgurl" />
    <result column="url" jdbcType="VARCHAR" property="url" />
    <result column="width" jdbcType="INTEGER" property="width" />
    <result column="height" jdbcType="INTEGER" property="height" />
    <result column="start_date" jdbcType="TIMESTAMP" property="startDate" />
    <result column="end_date" jdbcType="TIMESTAMP" property="endDate" />
  </resultMap>
  <sql id="Base_Column_List">
    id, sign, text, imgUrl, url, width, height, start_date, end_date
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from banners
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from banners
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.Banners">
    insert into banners (id, sign, text, 
      imgUrl, url, width, 
      height, start_date, end_date
      )
    values (#{id,jdbcType=BIGINT}, #{sign,jdbcType=VARCHAR}, #{text,jdbcType=VARCHAR}, 
      #{imgurl,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{width,jdbcType=INTEGER}, 
      #{height,jdbcType=INTEGER}, #{startDate,jdbcType=TIMESTAMP}, #{endDate,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.Banners">
    insert into banners
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="sign != null">
        sign,
      </if>
      <if test="text != null">
        text,
      </if>
      <if test="imgurl != null">
        imgUrl,
      </if>
      <if test="url != null">
        url,
      </if>
      <if test="width != null">
        width,
      </if>
      <if test="height != null">
        height,
      </if>
      <if test="startDate != null">
        start_date,
      </if>
      <if test="endDate != null">
        end_date,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="sign != null">
        #{sign,jdbcType=VARCHAR},
      </if>
      <if test="text != null">
        #{text,jdbcType=VARCHAR},
      </if>
      <if test="imgurl != null">
        #{imgurl,jdbcType=VARCHAR},
      </if>
      <if test="url != null">
        #{url,jdbcType=VARCHAR},
      </if>
      <if test="width != null">
        #{width,jdbcType=INTEGER},
      </if>
      <if test="height != null">
        #{height,jdbcType=INTEGER},
      </if>
      <if test="startDate != null">
        #{startDate,jdbcType=TIMESTAMP},
      </if>
      <if test="endDate != null">
        #{endDate,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Banners">
    update banners
    <set>
      <if test="sign != null">
        sign = #{sign,jdbcType=VARCHAR},
      </if>
      <if test="text != null">
        text = #{text,jdbcType=VARCHAR},
      </if>
      <if test="imgurl != null">
        imgUrl = #{imgurl,jdbcType=VARCHAR},
      </if>
      <if test="url != null">
        url = #{url,jdbcType=VARCHAR},
      </if>
      <if test="width != null">
        width = #{width,jdbcType=INTEGER},
      </if>
      <if test="height != null">
        height = #{height,jdbcType=INTEGER},
      </if>
      <if test="startDate != null">
        start_date = #{startDate,jdbcType=TIMESTAMP},
      </if>
      <if test="endDate != null">
        end_date = #{endDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Banners">
    update banners
    set sign = #{sign,jdbcType=VARCHAR},
      text = #{text,jdbcType=VARCHAR},
      imgUrl = #{imgurl,jdbcType=VARCHAR},
      url = #{url,jdbcType=VARCHAR},
      width = #{width,jdbcType=INTEGER},
      height = #{height,jdbcType=INTEGER},
      start_date = #{startDate,jdbcType=TIMESTAMP},
      end_date = #{endDate,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <select id="findBannerList" resultMap="BaseResultMap">
		select
		<include refid="Base_Column_List" />
		from banners where 1=1 
		<if test="sign != null">
			and sign = #{sign,jdbcType=VARCHAR}
		</if>
		order by id desc
		<if test="pageNo != null and pageSize != null">
		limit #{pageNo,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}
		</if>
	</select>
	<select id="findBannerListCount" parameterType="java.lang.String" resultType="java.lang.Integer">
		select count(1)
		from banners where 1=1 
		<if test="sign != null">
			and sign = #{sign,jdbcType=VARCHAR}
		</if>
	</select>
</mapper>