<?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.BBusiHollandRecordDetailsMapper">

  <resultMap type="BBusiHollandRecordDetails" id="BBusiHollandRecordDetailsResult">
    <result property="id" column="id" />
    <result property="customerCode" column="customerCode" />
    <result property="recordCode" column="recordCode" />
    <result property="stepId" column="stepId" />
    <result property="stepTitle" column="stepTitle" />
    <result property="questionId" column="questionId" />
    <result property="ruleCode" column="ruleCode" />
    <result property="questionTitle" column="questionTitle" />
    <result property="answer" column="answer" />
    <result property="status" column="status" />
  </resultMap>

  <sql id="selectBBusiHollandRecordDetailsVo">
    select id, customerCode, recordCode, stepId, stepTitle, questionId, ruleCode, questionTitle, answer, status from b_busi_holland_record_details
  </sql>

  <select id="selectBBusiHollandRecordDetailsList" parameterType="BBusiHollandRecordDetails" resultMap="BBusiHollandRecordDetailsResult">
    <include refid="selectBBusiHollandRecordDetailsVo" />
    <where>
      <if test="customerCode != null  and customerCode != ''"> and customerCode = #{customerCode}</if>
      <if test="recordCode != null  and recordCode != ''"> and recordCode = #{recordCode}</if>
      <if test="stepId != null "> and stepId = #{stepId}</if>
      <if test="stepTitle != null  and stepTitle != ''"> and stepTitle = #{stepTitle}</if>
      <if test="questionId != null "> and questionId = #{questionId}</if>
      <if test="ruleCode != null  and ruleCode != ''"> and ruleCode = #{ruleCode}</if>
      <if test="questionTitle != null  and questionTitle != ''"> and questionTitle = #{questionTitle}</if>
      <if test="answer != null  and answer != ''"> and answer = #{answer}</if>
      <if test="status != null "> and status = #{status}</if>
    </where>
  </select>

  <select id="selectBBusiHollandRecordDetailsById" parameterType="Long" resultMap="BBusiHollandRecordDetailsResult">
    <include refid="selectBBusiHollandRecordDetailsVo" />
    where id = #{id}
  </select>

  <insert id="insertBBusiHollandRecordDetails" parameterType="BBusiHollandRecordDetails" useGeneratedKeys="true" keyProperty="id">
    insert into b_busi_holland_record_details
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="customerCode != null and customerCode != ''">customerCode,</if>
      <if test="recordCode != null and recordCode != ''">recordCode,</if>
      <if test="stepId != null">stepId,</if>
      <if test="stepTitle != null and stepTitle != ''">stepTitle,</if>
      <if test="questionId != null">questionId,</if>
      <if test="ruleCode != null">ruleCode,</if>
      <if test="questionTitle != null">questionTitle,</if>
      <if test="answer != null">answer,</if>
      <if test="status != null">status,</if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="customerCode != null and customerCode != ''">#{customerCode},</if>
      <if test="recordCode != null and recordCode != ''">#{recordCode},</if>
      <if test="stepId != null">#{stepId},</if>
      <if test="stepTitle != null and stepTitle != ''">#{stepTitle},</if>
      <if test="questionId != null">#{questionId},</if>
      <if test="ruleCode != null">#{ruleCode},</if>
      <if test="questionTitle != null">#{questionTitle},</if>
      <if test="answer != null">#{answer},</if>
      <if test="status != null">#{status},</if>
    </trim>
  </insert>
  
  <insert id="insertBatch" parameterType="java.util.Collection"  useGeneratedKeys="true" keyProperty="id">
       INSERT INTO b_busi_holland_record_details(customerCode, recordCode, stepId,stepTitle,questionId,ruleCode,questionTitle,answer,status) 
       VALUES
      <foreach collection="list" item="item" index="index" separator=",">
      (#{item.customerCode}, #{item.recordCode}, #{item.stepId}, #{item.stepTitle}
      , #{item.questionId}, #{item.ruleCode}, #{item.questionTitle}, #{item.answer}, #{item.status})
      </foreach>
      ON DUPLICATE KEY UPDATE customerCode = VALUES(customerCode), recordCode = VALUES(recordCode), questionId = VALUES(questionId)
  </insert>

  <update id="updateBBusiHollandRecordDetails" parameterType="BBusiHollandRecordDetails">
    update b_busi_holland_record_details
    <trim prefix="SET" suffixOverrides=",">
      <if test="customerCode != null and customerCode != ''">customerCode = #{customerCode},</if>
      <if test="recordCode != null and recordCode != ''">recordCode = #{recordCode},</if>
      <if test="stepId != null">stepId = #{stepId},</if>
      <if test="stepTitle != null and stepTitle != ''">stepTitle = #{stepTitle},</if>
      <if test="questionId != null">questionId = #{questionId},</if>
      <if test="ruleCode != null">ruleCode = #{ruleCode},</if>
      <if test="questionTitle != null">questionTitle = #{questionTitle},</if>
      <if test="answer != null">answer = #{answer},</if>
      <if test="status != null">status = #{status},</if>
    </trim>
    where id = #{id}
  </update>

  <delete id="deleteBBusiHollandRecordDetailsById" parameterType="Long">
    delete from b_busi_holland_record_details where id = #{id}
  </delete>

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