<?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.ruoyi.syzy.mapper.BCustomerXkcxMapper">

  <resultMap type="BCustomerXkcx" id="BCustomerXkcxResult">
    <result property="id" column="id" />
    <result property="customerCode" column="customerCode" />
    <result property="submitId" column="submitId" />
    <result property="createTime" column="createTime" />
    <result property="status" column="status" />
    <result property="isSelectCourse" column="is_select_course" />
    <result property="roundId" column="round_id" />

    <association property="xkcx"    column="id" javaType="BBusiWishXkcx" resultMap="BBusiWishXkcxResult" />
  </resultMap>

  <resultMap type="BBusiWishXkcx" id="BBusiWishXkcxResult">
    <result property="id" column="xkcx_id" />
    <result property="year" column="year" />
    <result property="customerCode" column="customer_code" />
    <result property="location" column="location" />
    <result property="level" column="level" />
    <result property="marjorId" column="marjorId" />
    <result property="universityId" column="universityId" />
    <result property="universityName" column="universityName" />
    <result property="marjorName" column="marjorName" />
    <result property="marjorBelongs" column="marjorBelongs" />
    <result property="marjorDirection" column="marjorDirection" />
    <result property="courseRemark0" column="courseRemark0" />
    <result property="courseRemark1" column="courseRemark1" />
    <result property="course0" column="course0" />
    <result property="course1" column="course1" />
    <result property="course2" column="course2" />
    <result property="score" column="score" />
    <result property="seat" column="seat" />
    <result property="num" column="num" />
    <result property="numReal" column="numReal" />
    <result property="scoreRealTop" column="scoreRealTop" />
    <result property="seatRealTop" column="seatRealTop" />
    <result property="scoreRealAverage" column="scoreRealAverage" />
    <result property="seatRealAverage" column="seatRealAverage" />
    <result property="createTime" column="createTime" />
    <result property="status" column="status" />
  </resultMap>

  <sql id="selectBCustomerXkcxVo">
    select bcx.id, bcx.customerCode, bcx.submitId, bcx.createTime, bcx.status, bcx.is_select_course, bcx.round_id,
    bbwx.id xkcx_id, bbwx.year, bbwx.location, bbwx.level, bbwx.marjorId, bbwx.universityId, bbwx.universityName, bbwx.marjorName,
    bbwx.marjorBelongs, bbwx.marjorDirection, bbwx.courseRemark0, bbwx.courseRemark1, bbwx.course0, bbwx.course1, bbwx.course2,
    bbwx.score, bbwx.seat, bbwx.num, bbwx.numReal, bbwx.scoreRealTop, bbwx.seatRealTop, bbwx.scoreRealAverage, bbwx.seatRealAverage,
    bbwx.createTime, bbwx.status
    from b_customer_xkcx bcx
    LEFT JOIN b_busi_wish_xkcx bbwx on bcx.submitId = bbwx.id
  </sql>

  <select id="selectBCustomerXkcxList" parameterType="BCustomerXkcx" resultMap="BCustomerXkcxResult">
    <include refid="selectBCustomerXkcxVo" />
    <where>
      <if test="customerCode != null  and customerCode != ''"> and bcx.customerCode = #{customerCode}</if>
      <if test="submitId != null "> and bcx.submitId = #{submitId}</if>
      <if test="createTime != null "> and bcx.createTime = #{createTime}</if>
      <if test="status != null "> and bcx.status = #{status}</if>
      <if test="isSelectCourse != null "> and bcx.is_select_course = #{isSelectCourse}</if>
      <if test="roundId != null "> and bcx.round_id = #{roundId}</if>
    </where>
  </select>

  <select id="selectBCustomerXkcxList2" parameterType="BCustomerXkcx" resultMap="BCustomerXkcxResult">
    select bcx.* from b_customer_xkcx bcx
    <where>
      <if test="customerCode != null  and customerCode != ''"> and bcx.customerCode = #{customerCode}</if>
      <if test="submitId != null "> and bcx.submitId = #{submitId}</if>
      <if test="createTime != null "> and bcx.createTime = #{createTime}</if>
      <if test="status != null "> and bcx.status = #{status}</if>
      <if test="isSelectCourse != null "> and bcx.is_select_course = #{isSelectCourse}</if>
      <if test="roundId != null "> and bcx.round_id = #{roundId}</if>
    </where>
  </select>

  <select id="selectBCustomerXkcxById" parameterType="Long" resultMap="BCustomerXkcxResult">
    <include refid="selectBCustomerXkcxVo" />
    where bcx.id = #{id}
  </select>

  <insert id="insertBCustomerXkcx" parameterType="BCustomerXkcx" useGeneratedKeys="true" keyProperty="id">
    insert into b_customer_xkcx
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="customerCode != null">customerCode,</if>
      <if test="submitId != null">submitId,</if>
      <if test="createTime != null">createTime,</if>
      <if test="status != null">status,</if>
      <if test="isSelectCourse != null">is_select_course,</if>
      <if test="roundId != null">round_id,</if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="customerCode != null">#{customerCode},</if>
      <if test="submitId != null">#{submitId},</if>
      <if test="createTime != null">#{createTime},</if>
      <if test="status != null">#{status},</if>
      <if test="isSelectCourse != null">#{isSelectCourse},</if>
      <if test="roundId != null">#{roundId},</if>
    </trim>
  </insert>

  <update id="updateBCustomerXkcx" parameterType="BCustomerXkcx">
    update b_customer_xkcx
    <trim prefix="SET" suffixOverrides=",">
      <if test="customerCode != null">customerCode = #{customerCode},</if>
      <if test="submitId != null">submitId = #{submitId},</if>
      <if test="createTime != null">createTime = #{createTime},</if>
      <if test="status != null">status = #{status},</if>
      <if test="isSelectCourse != null">is_select_course = #{isSelectCourse},</if>
      <if test="roundId != null">round_id = #{roundId},</if>
    </trim>
    where id = #{id}
  </update>

  <delete id="deleteBCustomerXkcxById" parameterType="Long">
    delete from b_customer_xkcx where id = #{id}
  </delete>

  <delete id="deleteBCustomerXkcxByIds" parameterType="String">
    delete from b_customer_xkcx where id in
    <foreach item="id" collection="array" open="(" separator="," close=")">
      #{id}
    </foreach>
  </delete>
</mapper>