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

  <resultMap type="BBusiMbtiQuestions" id="BBusiMbtiQuestionsResult">
    <result property="id" column="id" />
    <result property="stepId" column="stepId" />
    <result property="no" column="no" />
    <result property="title" column="title" />
    <result property="optionA" column="option_a" />
    <result property="optionB" column="option_b" />
    <result property="valueA" column="value_a" />
    <result property="valueB" column="value_b" />
    <result property="status" column="status" />
  </resultMap>

  <sql id="selectBBusiMbtiQuestionsVo">
    select id, stepId, no, title, option_a, option_b, value_a, value_b, status from b_busi_mbti_questions
  </sql>

  <select id="selectBBusiMbtiQuestionsList" parameterType="BBusiMbtiQuestions" resultMap="BBusiMbtiQuestionsResult">
    <include refid="selectBBusiMbtiQuestionsVo" />
    <where>
      <if test="stepId != null "> and stepId = #{stepId}</if>
      <if test="no != null "> and no = #{no}</if>
      <if test="title != null  and title != ''"> and title = #{title}</if>
      <if test="optionA != null  and optionA != ''"> and option_a = #{optionA}</if>
      <if test="optionB != null  and optionB != ''"> and option_b = #{optionB}</if>
      <if test="valueA != null  and valueA != ''"> and value_a = #{valueA}</if>
      <if test="valueB != null  and valueB != ''"> and value_b = #{valueB}</if>
      <if test="status != null "> and status = #{status}</if>
    </where>
    order by no
  </select>

  <select id="selectBBusiMbtiQuestionsById" parameterType="Long" resultMap="BBusiMbtiQuestionsResult">
    <include refid="selectBBusiMbtiQuestionsVo" />
    where id = #{id}
  </select>

  <select id="selectByIdList" parameterType="java.util.Collection" resultMap="BBusiMbtiQuestionsResult">
    <include refid="selectBBusiMbtiQuestionsVo" />
    where id in
    <foreach item="id" collection="idList" open="(" separator="," close=")">#{id}</foreach>
  </select>


  <insert id="insertBBusiMbtiQuestions" parameterType="BBusiMbtiQuestions" useGeneratedKeys="true" keyProperty="id">
    insert into b_busi_mbti_questions
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="stepId != null">stepId,</if>
      <if test="no != null">no,</if>
      <if test="title != null">title,</if>
      <if test="optionA != null">option_a,</if>
      <if test="optionB != null">option_b,</if>
      <if test="valueA != null">value_a,</if>
      <if test="valueB != null">value_b,</if>
      <if test="status != null">status,</if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="stepId != null">#{stepId},</if>
      <if test="no != null">#{no},</if>
      <if test="title != null">#{title},</if>
      <if test="optionA != null">#{optionA},</if>
      <if test="optionB != null">#{optionB},</if>
      <if test="valueA != null">#{valueA},</if>
      <if test="valueB != null">#{valueB},</if>
      <if test="status != null">#{status},</if>
    </trim>
  </insert>

  <update id="updateBBusiMbtiQuestions" parameterType="BBusiMbtiQuestions">
    update b_busi_mbti_questions
    <trim prefix="SET" suffixOverrides=",">
      <if test="stepId != null">stepId = #{stepId},</if>
      <if test="no != null">no = #{no},</if>
      <if test="title != null">title = #{title},</if>
      <if test="optionA != null">option_a = #{optionA},</if>
      <if test="optionB != null">option_b = #{optionB},</if>
      <if test="valueA != null">value_a = #{valueA},</if>
      <if test="valueB != null">value_b = #{valueB},</if>
      <if test="status != null">status = #{status},</if>
    </trim>
    where id = #{id}
  </update>

  <delete id="deleteBBusiMbtiQuestionsById" parameterType="Long">
    delete from b_busi_mbti_questions where id = #{id}
  </delete>

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