<?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.cku.dao.CkuImageMapper" >
  <resultMap id="BaseResultMap" type="com.cku.model.CkuImage" >
    <id column="image_id" property="imageId" jdbcType="INTEGER" />
    <result column="image_min_url" property="imageMinUrl" jdbcType="VARCHAR" />
    <result column="image_max_url" property="imageMaxUrl" jdbcType="VARCHAR" />
    <result column="remarks" property="remarks" jdbcType="VARCHAR" />
    <result column="dog_class_id" property="dogClassId" jdbcType="INTEGER" />
    <result column="match_id" property="matchId" jdbcType="INTEGER" />
    <result column="match_hotel_id" property="matchHotelId" jdbcType="INTEGER" />
    <result column="match_referee_id" property="matchRefereeId" jdbcType="INTEGER" />
    <result column="match_venue_id" property="matchVenueId" jdbcType="INTEGER" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="showLocation_isTop" property="showLocationIsTop" jdbcType="VARCHAR"/>
  </resultMap>
  <sql id="Base_Column_List" >
    image_id, image_min_url, image_max_url, match_id, match_hotel_id, match_referee_id, 
    match_venue_id, create_time,remarks,dog_class_id,showLocation_isTop
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from cku_image
    where image_id = #{imageId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from cku_image
    where image_id = #{imageId,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.cku.model.CkuImage">
    insert into cku_image (image_id, image_min_url, image_max_url, 
      match_id, match_hotel_id, match_referee_id, 
      match_venue_id, create_time)
    values (#{imageId,jdbcType=INTEGER}, #{imageMinUrl,jdbcType=VARCHAR}, #{imageMaxUrl,jdbcType=VARCHAR}, 
      #{matchId,jdbcType=INTEGER}, #{matchHotelId,jdbcType=INTEGER}, #{matchRefereeId,jdbcType=INTEGER}, 
      #{matchVenueId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.cku.model.CkuImage" useGeneratedKeys="true" keyProperty="imageId">
    insert into cku_image
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="imageId != null" >
        image_id,
      </if>
      <if test="imageMinUrl != null" >
        image_min_url,
      </if>
      <if test="imageMaxUrl != null" >
        image_max_url,
      </if>
      <if test="remarks != null" >
        remarks,
      </if>
      <if test="dogClassId != null" >
        dog_class_id,
      </if>
      <if test="matchId != null" >
        match_id,
      </if>
      <if test="matchHotelId != null" >
        match_hotel_id,
      </if>
      <if test="matchRefereeId != null" >
        match_referee_id,
      </if>
      <if test="matchVenueId != null" >
        match_venue_id,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
      <if test="showLocation != null" >
        showLocation,
      </if>
      <if test="showLocationIsTop!=null">
      showLocation_isTop,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="imageId != null" >
        #{imageId,jdbcType=INTEGER},
      </if>
      <if test="imageMinUrl != null" >
        #{imageMinUrl,jdbcType=VARCHAR},
      </if>
      <if test="imageMaxUrl != null" >
        #{imageMaxUrl,jdbcType=VARCHAR},
      </if>
      <if test="remarks != null" >
         #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="dogClassId != null" >
         #{dogClassId,jdbcType=VARCHAR},
      </if>
      <if test="matchId != null" >
        #{matchId,jdbcType=VARCHAR},
      </if>
      <if test="matchHotelId != null" >
        #{matchHotelId,jdbcType=VARCHAR},
      </if>
      <if test="matchRefereeId != null" >
        #{matchRefereeId,jdbcType=VARCHAR},
      </if>
      <if test="matchVenueId != null" >
        #{matchVenueId,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="showLocation != null" >
        #{showLocation,jdbcType=VARCHAR},
      </if>
      <if test="showLocationIsTop!=null">
      #{showLocationIsTop,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.cku.model.CkuImage" >
    update cku_image
    <set >
      <if test="imageMinUrl != null" >
        image_min_url = #{imageMinUrl,jdbcType=VARCHAR},
      </if>
      <if test="imageMaxUrl != null" >
        image_max_url = #{imageMaxUrl,jdbcType=VARCHAR},
      </if>
      <if test="matchId != null" >
        match_id = #{matchId,jdbcType=INTEGER},
      </if>
      <if test="matchHotelId != null" >
        match_hotel_id = #{matchHotelId,jdbcType=INTEGER},
      </if>
      <if test="matchRefereeId != null" >
        match_referee_id = #{matchRefereeId,jdbcType=INTEGER},
      </if>
      <if test="matchVenueId != null" >
        match_venue_id = #{matchVenueId,jdbcType=INTEGER},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="showLocationIsTop!=null">
      	showLocation_isTop=#{showLocationIsTop,jdbcType=VARCHAR},
      </if>
    </set>
    where image_id = #{imageId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.cku.model.CkuImage" >
    update cku_image
    set image_min_url = #{imageMinUrl,jdbcType=VARCHAR},
      image_max_url = #{imageMaxUrl,jdbcType=VARCHAR},
      match_id = #{matchId,jdbcType=INTEGER},
      match_hotel_id = #{matchHotelId,jdbcType=INTEGER},
      match_referee_id = #{matchRefereeId,jdbcType=INTEGER},
      match_venue_id = #{matchVenueId,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where image_id = #{imageId,jdbcType=INTEGER}
  </update>
    <select id="selectByColumn" resultMap="BaseResultMap" parameterType="java.lang.String" >
    ${sql}
  	</select>
  	
  	<!-- 查询酒店配图 -->
  	<select id="getImageById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  	select image_id,image_max_url,image_min_url from cku_image where match_hotel_id=#{hotelId}
  	</select>
  	<!-- 查询场馆配图 -->
  	<select id="getVenueImage" resultMap="BaseResultMap">
  	select image_id,image_max_url,image_min_url from cku_image where match_venue_id=#{venueId}
  	</select>

</mapper>