<?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.CkuCaiPanMapper" >
  <resultMap id="BaseResultMap" type="com.cku.model.CkuCaiPan" >
    <result column="id" property="id" jdbcType="INTEGER" />
    <result column="cku_title" property="ckuTitle" jdbcType="VARCHAR" />
    <result column="cku_picture" property="ckuPicture" jdbcType="VARCHAR" />
    <result column="cku_zhijiao" property="ckuZhijiao" jdbcType="VARCHAR" />
    <result column="cku_country" property="ckuCountry" jdbcType="VARCHAR" />
    <result column="cku_content" property="ckuContent" jdbcType="VARCHAR" />
    <result column="cku_position" property="ckuPosition" jdbcType="VARCHAR" />
    <result column="cku_sex" property="ckuSex" jdbcType="VARCHAR" />
    <result column="cku_ssbh" property="ckuSsbh" jdbcType="VARCHAR" />
    <result column="cku_sczz" property="ckuSczz" jdbcType="VARCHAR" />
    <result column="cku_position" property="ckuPosition" jdbcType="VARCHAR" />
    <result property="imageMinUrl" column="image_min_url"/>
	<result property="imageMaxUrl" column="image_max_url"/>
  </resultMap>
  <!--SQL SERVER 根据裁判ids获取裁判的信息列表 -->
  <select id="getRefereeMessage" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  	SELECT
	    caipan.id,caipan.judge_name cku_title,caipan.judge_title cku_position, image.image_min_url,
	    image.image_max_url
	FROM
	    show_judge caipan
	LEFT JOIN cku_image image ON caipan.id = image.match_referee_id
	<if test="ids != null and ids != ''">
	WHERE
	    caipan.id IN (${ids})
	</if>
  </select>
  <sql id="Blob_Column_List" >
    cku_content, cku_position
  </sql>
  <insert id="insert" parameterType="com.cku.model.CkuCaiPan" >
    insert into cku_caipan (id, cku_title, cku_picture, 
      cku_zhijiao, cku_country, cku_sex, 
      cku_ssbh, cku_sczz, cku_content, 
      cku_position)
    values (#{id,jdbcType=INTEGER}, #{ckuTitle,jdbcType=VARCHAR}, #{ckuPicture,jdbcType=VARCHAR}, 
      #{ckuZhijiao,jdbcType=VARCHAR}, #{ckuCountry,jdbcType=VARCHAR}, #{ckuSex,jdbcType=VARCHAR}, 
      #{ckuSsbh,jdbcType=VARCHAR}, #{ckuSczz,jdbcType=VARCHAR}, #{ckuContent,jdbcType=LONGVARCHAR}, 
      #{ckuPosition,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.cku.model.CkuCaiPan" >
    insert into cku_caipan
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="ckuTitle != null" >
        cku_title,
      </if>
      <if test="ckuPicture != null" >
        cku_picture,
      </if>
      <if test="ckuZhijiao != null" >
        cku_zhijiao,
      </if>
      <if test="ckuCountry != null" >
        cku_country,
      </if>
      <if test="ckuSex != null" >
        cku_sex,
      </if>
      <if test="ckuSsbh != null" >
        cku_ssbh,
      </if>
      <if test="ckuSczz != null" >
        cku_sczz,
      </if>
      <if test="ckuContent != null" >
        cku_content,
      </if>
      <if test="ckuPosition != null" >
        cku_position,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="ckuTitle != null" >
        #{ckuTitle,jdbcType=VARCHAR},
      </if>
      <if test="ckuPicture != null" >
        #{ckuPicture,jdbcType=VARCHAR},
      </if>
      <if test="ckuZhijiao != null" >
        #{ckuZhijiao,jdbcType=VARCHAR},
      </if>
      <if test="ckuCountry != null" >
        #{ckuCountry,jdbcType=VARCHAR},
      </if>
      <if test="ckuSex != null" >
        #{ckuSex,jdbcType=VARCHAR},
      </if>
      <if test="ckuSsbh != null" >
        #{ckuSsbh,jdbcType=VARCHAR},
      </if>
      <if test="ckuSczz != null" >
        #{ckuSczz,jdbcType=VARCHAR},
      </if>
      <if test="ckuContent != null" >
        #{ckuContent,jdbcType=LONGVARCHAR},
      </if>
      <if test="ckuPosition != null" >
        #{ckuPosition,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <!--  -->
   <select id="getList" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
	SELECT id,judge_name cku_title,judge_title cku_position FROM show_judge 
	where 1 = 1
	<if test="name != '' and  name != null" >
		and judge_name like '%${name}%'
    </if>
	<if test="position != '' and  position != null" >
		and judge_title like '%${position}%'
    </if>
	ORDER BY ID DESC  limit ${count},${limit}

  </select>
  <select id="getCaiPan" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
	SELECT  * FROM cku_caipan  
  </select>
  <select id="getCount" resultType="java.lang.Long" parameterType="java.lang.Integer" >
    SELECT
		count(*)
	FROM show_judge 
	WHERE 1=1 
	<if test="name != '' and  name != null" >
		and judge_name like '%${name}%'
    </if>
	<if test="position != '' and  position != null" >
		and judge_title like '%${position}%'
    </if>
  </select>
  <!-- 更改裁判信息-->
  <update id="updateByPrimaryKeySelective" parameterType="com.cku.model.CkuCaiPan">
	update cku_caipan
	<set>
		<if test="ckuTitle != null">
			cku_title = #{ckuTitle,jdbcType=VARCHAR},
		</if>
		<if test="ckuPicture != null">
			cku_picture = #{ckuPicture,jdbcType=VARCHAR},
		</if>
		<if test="ckuZhijiao != null">
			cku_zhijiao = #{ckuZhijiao,jdbcType=VARCHAR},
		</if>
		<if test="ckuCountry != null">
			cku_country = #{ckuCountry,jdbcType=VARCHAR},
		</if>
		<if test="ckuSex != null">
			cku_sex = #{ckuSex,jdbcType=VARCHAR},
		</if>
		<if test="ckuSsbh != null">
			cku_ssbh = #{ckuSsbh,jdbcType=VARCHAR},
		</if>
		<if test="ckuSczz != null">
			cku_sczz = #{ckuSczz,jdbcType=VARCHAR},
		</if>
		<if test="ckuContent != null">
			cku_content = #{ckuContent,jdbcType=LONGVARCHAR},
		</if>
		<if test="ckuPosition != null">
			cku_position = #{ckuPosition,jdbcType=LONGVARCHAR},
		</if>
	</set>
	where id=#{id,jdbcType=INTEGER}
  </update>
  <!--删除裁判 -->
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  delete from cku_caipan
  where id=#{id,jdbcType=INTEGER}
  </delete>
  <!-- 查询所有裁判 -->
  <select id="getCaiPanById" resultMap="BaseResultMap" parameterType="java.lang.Integer">
  select * from cku_caipan where id=#{id,jdbcType=INTEGER}
  </select>
</mapper>