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

  <resultMap type="BBusiMbtiRules" id="BBusiMbtiRulesResult">
    <result property="id" column="id" />
    <result property="code" column="code" />
    <result property="name" column="name" />
    <result property="title" column="title" />
    <result property="status" column="status" />
  </resultMap>

  <sql id="selectBBusiMbtiRulesVo">
    select id, code, name, title, status from b_busi_mbti_rules
  </sql>

  <select id="selectBBusiMbtiRulesList" parameterType="BBusiMbtiRules" resultMap="BBusiMbtiRulesResult">
    <include refid="selectBBusiMbtiRulesVo" />
    <where>
      <if test="code != null  and code != ''"> and code = #{code}</if>
      <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
      <if test="title != null  and title != ''"> and title = #{title}</if>
      <if test="status != null "> and status = #{status}</if>
    </where>
  </select>

  <select id="selectBBusiMbtiRulesById" parameterType="Long" resultMap="BBusiMbtiRulesResult">
    <include refid="selectBBusiMbtiRulesVo" />
    where id = #{id}
  </select>

  <insert id="insertBBusiMbtiRules" parameterType="BBusiMbtiRules" useGeneratedKeys="true" keyProperty="id">
    insert into b_busi_mbti_rules
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="code != null and code != ''">code,</if>
      <if test="name != null">name,</if>
      <if test="title != null and title != ''">title,</if>
      <if test="status != null">status,</if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="code != null and code != ''">#{code},</if>
      <if test="name != null">#{name},</if>
      <if test="title != null and title != ''">#{title},</if>
      <if test="status != null">#{status},</if>
    </trim>
  </insert>

  <update id="updateBBusiMbtiRules" parameterType="BBusiMbtiRules">
    update b_busi_mbti_rules
    <trim prefix="SET" suffixOverrides=",">
      <if test="code != null and code != ''">code = #{code},</if>
      <if test="name != null">name = #{name},</if>
      <if test="title != null and title != ''">title = #{title},</if>
      <if test="status != null">status = #{status},</if>
    </trim>
    where id = #{id}
  </update>

  <delete id="deleteBBusiMbtiRulesById" parameterType="Long">
    delete from b_busi_mbti_rules where id = #{id}
  </delete>

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