<?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">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Aug 30 08:27:53 CST 2018.
    -->
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="text" jdbcType="VARCHAR" property="text" />
    <result column="img_url" jdbcType="VARCHAR" property="imgUrl" />
    <result column="api_url" jdbcType="VARCHAR" property="apiUrl" />
    <result column="forward_url" jdbcType="VARCHAR" property="forwardUrl" />
    <result column="width" jdbcType="INTEGER" property="width" />
    <result column="height" jdbcType="INTEGER" property="height" />
    <result column="client" jdbcType="INTEGER" property="client" />
    <result column="delete_sign" jdbcType="BIT" property="deleteSign" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Aug 30 08:27:53 CST 2018.
    -->
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <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 close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Aug 30 08:27:53 CST 2018.
    -->
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <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 close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Aug 30 08:27:53 CST 2018.
    -->
    id, text, img_url, api_url, forward_url, width, height, client, delete_sign
  </sql>
  <select id="selectByExample" parameterType="com.goafanti.common.model.BannersExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Aug 30 08:27:53 CST 2018.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from banners
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Aug 30 08:27:53 CST 2018.
    -->
    select 
    <include refid="Base_Column_List" />
    from banners
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Aug 30 08:27:53 CST 2018.
    -->
    delete from banners
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.goafanti.common.model.BannersExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Aug 30 08:27:53 CST 2018.
    -->
    delete from banners
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.Banners">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Aug 30 08:27:53 CST 2018.
    -->
    insert into banners (id, text, img_url, 
      api_url, forward_url, width, 
      height, client, delete_sign
      )
    values (#{id,jdbcType=VARCHAR}, #{text,jdbcType=VARCHAR}, #{imgUrl,jdbcType=VARCHAR}, 
      #{apiUrl,jdbcType=VARCHAR}, #{forwardUrl,jdbcType=VARCHAR}, #{width,jdbcType=INTEGER}, 
      #{height,jdbcType=INTEGER}, #{client,jdbcType=INTEGER}, #{deleteSign,jdbcType=BIT}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.Banners">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Aug 30 08:27:53 CST 2018.
    -->
    insert into banners
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="text != null">
        text,
      </if>
      <if test="imgUrl != null">
        img_url,
      </if>
      <if test="apiUrl != null">
        api_url,
      </if>
      <if test="forwardUrl != null">
        forward_url,
      </if>
      <if test="width != null">
        width,
      </if>
      <if test="height != null">
        height,
      </if>
      <if test="client != null">
        client,
      </if>
      <if test="deleteSign != null">
        delete_sign,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="text != null">
        #{text,jdbcType=VARCHAR},
      </if>
      <if test="imgUrl != null">
        #{imgUrl,jdbcType=VARCHAR},
      </if>
      <if test="apiUrl != null">
        #{apiUrl,jdbcType=VARCHAR},
      </if>
      <if test="forwardUrl != null">
        #{forwardUrl,jdbcType=VARCHAR},
      </if>
      <if test="width != null">
        #{width,jdbcType=INTEGER},
      </if>
      <if test="height != null">
        #{height,jdbcType=INTEGER},
      </if>
      <if test="client != null">
        #{client,jdbcType=INTEGER},
      </if>
      <if test="deleteSign != null">
        #{deleteSign,jdbcType=BIT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.goafanti.common.model.BannersExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Aug 30 08:27:53 CST 2018.
    -->
    select count(*) from banners
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Aug 30 08:27:53 CST 2018.
    -->
    update banners
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.text != null">
        text = #{record.text,jdbcType=VARCHAR},
      </if>
      <if test="record.imgUrl != null">
        img_url = #{record.imgUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.apiUrl != null">
        api_url = #{record.apiUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.forwardUrl != null">
        forward_url = #{record.forwardUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.width != null">
        width = #{record.width,jdbcType=INTEGER},
      </if>
      <if test="record.height != null">
        height = #{record.height,jdbcType=INTEGER},
      </if>
      <if test="record.client != null">
        client = #{record.client,jdbcType=INTEGER},
      </if>
      <if test="record.deleteSign != null">
        delete_sign = #{record.deleteSign,jdbcType=BIT},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Aug 30 08:27:53 CST 2018.
    -->
    update banners
    set id = #{record.id,jdbcType=VARCHAR},
      text = #{record.text,jdbcType=VARCHAR},
      img_url = #{record.imgUrl,jdbcType=VARCHAR},
      api_url = #{record.apiUrl,jdbcType=VARCHAR},
      forward_url = #{record.forwardUrl,jdbcType=VARCHAR},
      width = #{record.width,jdbcType=INTEGER},
      height = #{record.height,jdbcType=INTEGER},
      client = #{record.client,jdbcType=INTEGER},
      delete_sign = #{record.deleteSign,jdbcType=BIT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Banners">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Aug 30 08:27:53 CST 2018.
    -->
    update banners
    <set>
      <if test="text != null">
        text = #{text,jdbcType=VARCHAR},
      </if>
      <if test="imgUrl != null">
        img_url = #{imgUrl,jdbcType=VARCHAR},
      </if>
      <if test="apiUrl != null">
        api_url = #{apiUrl,jdbcType=VARCHAR},
      </if>
      <if test="forwardUrl != null">
        forward_url = #{forwardUrl,jdbcType=VARCHAR},
      </if>
      <if test="width != null">
        width = #{width,jdbcType=INTEGER},
      </if>
      <if test="height != null">
        height = #{height,jdbcType=INTEGER},
      </if>
      <if test="client != null">
        client = #{client,jdbcType=INTEGER},
      </if>
      <if test="deleteSign != null">
        delete_sign = #{deleteSign,jdbcType=BIT},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Banners">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Aug 30 08:27:53 CST 2018.
    -->
    update banners
    set text = #{text,jdbcType=VARCHAR},
      img_url = #{imgUrl,jdbcType=VARCHAR},
      api_url = #{apiUrl,jdbcType=VARCHAR},
      forward_url = #{forwardUrl,jdbcType=VARCHAR},
      width = #{width,jdbcType=INTEGER},
      height = #{height,jdbcType=INTEGER},
      client = #{client,jdbcType=INTEGER},
      delete_sign = #{deleteSign,jdbcType=BIT}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <select id="findBannerList" resultMap="BaseResultMap">
  select
  <include refid="Base_Column_List" /> 
 	from banners
	where delete_sign=0
	<if test="apiUrl != null">
	and api_url= #{apiUrl,jdbcType=VARCHAR}
	</if>
	<if test="client != null">
	and client= #{client,jdbcType=INTEGER}
	</if>
	<if test="pN != null and pS != null">
	limit #{pN,jdbcType=INTEGER},#{pS,jdbcType=INTEGER}
	</if>
  </select>
  <select id="findAdminBannersList" resultMap="BaseResultMap">
  	select
  <include refid="Base_Column_List" /> 
 	from banners
 	where delete_sign=0
	<if test="apiUrl != null">
	and api_url= #{apiUrl,jdbcType=VARCHAR}
	</if>
	<if test="client != null">
	and client= #{client,jdbcType=INTEGER}
	</if>
	<if test="page_sql!=null">
			${page_sql}
	</if>
  </select>
  <select id="findAdminBannersCount" resultType="java.lang.Integer">
  	select
  	count(*)
 	from banners
 	where delete_sign=0
	<if test="apiUrl != null">
	and api_url= #{apiUrl,jdbcType=VARCHAR}
	</if>
	<if test="client != null">
	and client= #{client,jdbcType=INTEGER}
	</if>
  </select>
</mapper>