<?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.CkuMatchMapper" >
  <resultMap id="BaseResultMap" type="com.cku.model.CkuMatch" >
    <result column="id" property="id" jdbcType="VARCHAR" />
    <result column="showSystem" property="showsystem" jdbcType="CHAR" />
    <result column="show_num" property="showNum" jdbcType="VARCHAR" />
    <result column="starting_data" property="startingData" jdbcType="TIMESTAMP" />
    <result column="ending_data" property="endingData" jdbcType="TIMESTAMP" />
    <result column="show_name" property="showName" jdbcType="VARCHAR" />
    <result column="show_location" property="showLocation" jdbcType="VARCHAR" />
    <result column="show_enrolment" property="showEnrolment" jdbcType="VARCHAR" />
    <result column="add_data" property="addData" jdbcType="TIMESTAMP" />
    <result column="modifi_data" property="modifiData" jdbcType="TIMESTAMP" />
    <result column="bmFei" property="bmfei" jdbcType="DECIMAL" />
    <result column="del_tag" property="delTag" jdbcType="CHAR" />
    <result column="cku_endtime" property="ckuEndtime" jdbcType="TIMESTAMP" />
    <result column="cku_zhuantiweb" property="ckuZhuantiweb" jdbcType="VARCHAR" />
    <result column="cku_picture1" property="ckuPicture1" jdbcType="VARCHAR" />
    <result column="cku_picture2" property="ckuPicture2" jdbcType="VARCHAR" />
    <result column="cku_caipanid" property="ckuCaipanid" jdbcType="VARCHAR" />
    <result column="cku_picture3" property="ckuPicture3" jdbcType="VARCHAR" />
    <result column="cku_tel" property="ckuTel" jdbcType="VARCHAR" />
    <result column="cku_tableweb" property="ckuTableweb" jdbcType="VARCHAR" />
    <result column="cku_slzweb" property="ckuSlzweb" jdbcType="VARCHAR" />
    <result column="cku_gjdlweb" property="ckuGjdlweb" jdbcType="VARCHAR" />
    <result column="cku_jfweb" property="ckuJfweb" jdbcType="VARCHAR" />
    <result column="privileges_enrolment" property="privilegesEnrolment" jdbcType="VARCHAR" />
    <result column="gameType" property="gametype" jdbcType="CHAR" />
    <result column="organizer" property="organizer" jdbcType="CHAR" />
    <result column="showCancel" property="showcancel" jdbcType="CHAR" />
    <result column="venue_id" property="venueId" jdbcType="VARCHAR" />
    <result column="main_game_name" jdbcType="VARCHAR" property="mainGameName" />
	<result column="top_dog" jdbcType="VARCHAR" property="topDog" />
	<result column="shows_detail" jdbcType="VARCHAR" property="showsDetail" />
  </resultMap>
  <sql id="Blob_Column_List" >
    d_content, d_content1, d_content2
  </sql>
  <insert id="insert" parameterType="com.cku.model.CkuMatchWithBLOBs" >
    insert into tab_games (id, showSystem, show_num, 
      starting_data, ending_data, show_name, 
      show_location, show_enrolment, add_data, 
      modifi_data, bmFei, del_tag, 
      cku_endtime, cku_zhuantiweb, cku_picture1, 
      cku_picture2, cku_caipanid, cku_picture3, 
      cku_tel, cku_tableweb, cku_slzweb, 
      cku_gjdlweb, cku_jfweb, privileges_enrolment, 
      gameType, organizer, showCancel, 
      venue_id, d_content,
      d_content1, d_content2)
    values (#{id,jdbcType=INTEGER}, #{showsystem,jdbcType=CHAR}, #{showNum,jdbcType=VARCHAR}, 
      #{startingData,jdbcType=TIMESTAMP}, #{endingData,jdbcType=TIMESTAMP}, #{showName,jdbcType=VARCHAR}, 
      #{showLocation,jdbcType=VARCHAR}, #{showEnrolment,jdbcType=VARCHAR}, #{addData,jdbcType=TIMESTAMP}, 
      #{modifiData,jdbcType=TIMESTAMP}, #{bmfei,jdbcType=DECIMAL}, #{delTag,jdbcType=CHAR}, 
      #{ckuEndtime,jdbcType=TIMESTAMP}, #{ckuZhuantiweb,jdbcType=VARCHAR}, #{ckuPicture1,jdbcType=VARCHAR}, 
      #{ckuPicture2,jdbcType=VARCHAR}, #{ckuCaipanid,jdbcType=VARCHAR}, #{ckuPicture3,jdbcType=VARCHAR}, 
      #{ckuTel,jdbcType=VARCHAR}, #{ckuTableweb,jdbcType=VARCHAR}, #{ckuSlzweb,jdbcType=VARCHAR}, 
      #{ckuGjdlweb,jdbcType=VARCHAR}, #{ckuJfweb,jdbcType=VARCHAR}, #{privilegesEnrolment,jdbcType=VARCHAR}, 
      #{gametype,jdbcType=CHAR}, #{organizer,jdbcType=CHAR}, #{showcancel,jdbcType=CHAR}, 
      #{venueId,jdbcType=INTEGER}, #{dContent,jdbcType=LONGVARCHAR},
      #{dContent1,jdbcType=LONGVARCHAR}, #{dContent2,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.cku.model.CkuMatchWithBLOBs" >
    insert into tab_games
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="showsystem != null" >
        showSystem,
      </if>
      <if test="showNum != null" >
       	 赛事编号,
      </if>
      <if test="startingData != null" >
        开始日期,
      </if>
      <if test="endingData != null" >
        结束日期,
      </if>
      <if test="showName != null" >
        赛事名称,
      </if>
      <if test="showLocation != null" >
        赛事地点,
      </if>
      <if test="showEnrolment != null" >
        赛事报名,
      </if>
      <if test="addData != null" >
        添加日期,
      </if>
      <if test="modifiData != null" >
       修改日期,
      </if>
      <if test="bmfei != null" >
        bmFei,
      </if>
      <if test="delTag != null" >
        del_tag,
      </if>
      <if test="ckuEndtime != null" >
        cku_endtime,
      </if>
      <if test="ckuZhuantiweb != null" >
        cku_zhuantiweb,
      </if>
      <if test="ckuPicture1 != null" >
        cku_picture1,
      </if>
      <if test="ckuPicture2 != null" >
        cku_picture2,
      </if>
      <if test="ckuCaipanid != null" >
        cku_caipanid,
      </if>
      <if test="ckuPicture3 != null" >
        cku_picture3,
      </if>
      <if test="ckuTel != null" >
        cku_tel,
      </if>
      <if test="ckuTableweb != null" >
        cku_tableweb,
      </if>
      <if test="ckuSlzweb != null" >
        cku_slzweb,
      </if>
      <if test="ckuGjdlweb != null" >
        cku_gjdlweb,
      </if>
      <if test="ckuJfweb != null" >
        cku_jfweb,
      </if>
      <if test="privilegesEnrolment != null" >
        报名优惠,
      </if>
      <if test="gametype != null" >
        gameType,
      </if>
      <if test="organizer != null" >
        organizer,
      </if>
      <if test="showcancel != null" >
        showCancel,
      </if>
      <if test="venueId != null" >
        venue_id,
      </if>
      <if test="dContent != null" >
        d_content,
      </if>
      <if test="dContent1 != null" >
        d_content1,
      </if>
      <if test="dContent2 != null" >
        d_content2,
      </if>
      <if test="mainGameName != null" >
        main_game_name,
      </if>
      <if test="topDog != null" >
        top_dog,
      </if>
      <if test="showsDetail != null" >
        shows_detail,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="showsystem != null" >
        #{showsystem,jdbcType=CHAR},
      </if>
      <if test="showNum != null" >
        #{showNum,jdbcType=VARCHAR},
      </if>
      <if test="startingData != null" >
        #{startingData,jdbcType=TIMESTAMP},
      </if>
      <if test="endingData != null" >
        #{endingData,jdbcType=TIMESTAMP},
      </if>
      <if test="showName != null" >
        #{showName,jdbcType=VARCHAR},
      </if>
      <if test="showLocation != null" >
        #{showLocation,jdbcType=VARCHAR},
      </if>
      <if test="showEnrolment != null" >
        #{showEnrolment,jdbcType=VARCHAR},
      </if>
      <if test="addData != null" >
        #{addData,jdbcType=TIMESTAMP},
      </if>
      <if test="modifiData != null" >
        #{modifiData,jdbcType=TIMESTAMP},
      </if>
      <if test="bmfei != null" >
        #{bmfei,jdbcType=DECIMAL},
      </if>
      <if test="delTag != null" >
        #{delTag,jdbcType=CHAR},
      </if>
      <if test="ckuEndtime != null" >
        #{ckuEndtime,jdbcType=TIMESTAMP},
      </if>
      <if test="ckuZhuantiweb != null" >
        #{ckuZhuantiweb,jdbcType=VARCHAR},
      </if>
      <if test="ckuPicture1 != null" >
        #{ckuPicture1,jdbcType=VARCHAR},
      </if>
      <if test="ckuPicture2 != null" >
        #{ckuPicture2,jdbcType=VARCHAR},
      </if>
      <if test="ckuCaipanid != null" >
        #{ckuCaipanid,jdbcType=VARCHAR},
      </if>
      <if test="ckuPicture3 != null" >
        #{ckuPicture3,jdbcType=VARCHAR},
      </if>
      <if test="ckuTel != null" >
        #{ckuTel,jdbcType=VARCHAR},
      </if>
      <if test="ckuTableweb != null" >
        #{ckuTableweb,jdbcType=VARCHAR},
      </if>
      <if test="ckuSlzweb != null" >
        #{ckuSlzweb,jdbcType=VARCHAR},
      </if>
      <if test="ckuGjdlweb != null" >
        #{ckuGjdlweb,jdbcType=VARCHAR},
      </if>
      <if test="ckuJfweb != null" >
        #{ckuJfweb,jdbcType=VARCHAR},
      </if>
      <if test="privilegesEnrolment != null" >
        #{privilegesEnrolment,jdbcType=VARCHAR},
      </if>
      <if test="gametype != null" >
        #{gametype},
      </if>
      <if test="organizer != null" >
        #{organizer,jdbcType=CHAR},
      </if>
      <if test="showcancel != null" >
        #{showcancel,jdbcType=CHAR},
      </if>
      <if test="venueId != null" >
        #{venueId,jdbcType=INTEGER},
      </if>
      <if test="dContent != null" >
        #{dContent,jdbcType=LONGVARCHAR},
      </if>
      <if test="dContent1 != null" >
        #{dContent1,jdbcType=LONGVARCHAR},
      </if>
      <if test="dContent2 != null" >
        #{dContent2,jdbcType=LONGVARCHAR},
      </if>
      <if test="mainGameName != null" >
        #{mainGameName,jdbcType=VARCHAR},
      </if>
      <if test="topDog != null" >
        #{topDog,jdbcType=VARCHAR},
      </if>
      <if test="showsDetail != null" >
        #{showsDetail,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="getMatchList" resultMap="BaseResultMap" parameterType="java.lang.Integer">
      SELECT
		   id,
		   isTop,
		   show_location
		FROM
		   (
		      SELECT
		         id AS id,
		         isTop AS isTop,
		         show_location AS show_location,
		         closing_time AS closing_time
		      FROM
		         show_main
		   ) ckuMatch
		<if test="keyword !=null and keyword !=''">
		WHERE
           show_location LIKE '%${keyword}%' 
		</if>
		order by closing_time desc 
		limit ${start},${limit}
  </select>
  <select id="getMatchCount" resultType="java.lang.Long" parameterType="java.lang.Integer">
      select count(*) as countNum from ( select id AS id,show_location as show_location from show_main) ckuMatch where show_location like '%${keyword}%'
  </select>
  <!--  -->
  <select id="getMatchById" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select
       id id,  
	   show_location,
	   referee cku_caipanid,
	   venues_id venue_id
     from show_main
    where id = #{id,jdbcType=VARCHAR}
  </select>
<update id="updateOfAdmin" parameterType="com.cku.model.CkuMatch" >
    update show_main
    <set >
        referee = #{ckuCaipanid,jdbcType=VARCHAR},
        venues_id = #{venueId,jdbcType=VARCHAR}
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
    <!--查询赛事信息 ******** -->
  <select id="getMatchMessage" parameterType="java.lang.String" resultType="java.lang.String">
  select 赛事名称 show_name from tab_games where 赛事编号 =#{showNum} AND del_flag = '0'
  </select>
</mapper>