<?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.CkuMatchRefereeMapper" >
  <resultMap id="BaseResultMap" type="com.cku.model.CkuMatchReferee" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="referee_name" property="refereeName" jdbcType="VARCHAR" />
    <result column="referee_nationality" property="refereeNationality" jdbcType="VARCHAR" />
    <result column="referee_info" property="refereeInfo" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, referee_name, referee_nationality, referee_info, create_time
  </sql>
  <!-- 根据赛事场馆名称查询裁判信息 zhuoHeng -->
  <select id="getRefereeMessage" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select ref.id,
       ref.referee_name,
       ref.referee_nationality,
       ref.referee_info,
       ref.create_time
	from cku_match_referee ref
	left join cku_match_referee_relation relation ON ref.id = relation.referee_id
	where relation.show_location = #{showLocation,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from cku_match_referee
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.cku.model.CkuMatchReferee" >
    insert into cku_match_referee (id, referee_name, referee_nationality, 
      referee_info, create_time)
    values (#{id,jdbcType=INTEGER}, #{refereeName,jdbcType=VARCHAR}, #{refereeNationality,jdbcType=VARCHAR}, 
      #{refereeInfo,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.cku.model.CkuMatchReferee" >
    insert into cku_match_referee
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="refereeName != null" >
        referee_name,
      </if>
      <if test="refereeNationality != null" >
        referee_nationality,
      </if>
      <if test="refereeInfo != null" >
        referee_info,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="refereeName != null" >
        #{refereeName,jdbcType=VARCHAR},
      </if>
      <if test="refereeNationality != null" >
        #{refereeNationality,jdbcType=VARCHAR},
      </if>
      <if test="refereeInfo != null" >
        #{refereeInfo,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.cku.model.CkuMatchReferee" >
    update cku_match_referee
    <set >
      <if test="refereeName != null" >
        referee_name = #{refereeName,jdbcType=VARCHAR},
      </if>
      <if test="refereeNationality != null" >
        referee_nationality = #{refereeNationality,jdbcType=VARCHAR},
      </if>
      <if test="refereeInfo != null" >
        referee_info = #{refereeInfo,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.cku.model.CkuMatchReferee" >
    update cku_match_referee
    set referee_name = #{refereeName,jdbcType=VARCHAR},
      referee_nationality = #{refereeNationality,jdbcType=VARCHAR},
      referee_info = #{refereeInfo,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>