<?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.voluntary.mapper.BusiGradeMapper">
    
    <resultMap type="BusiGrade" id="BusiGradeResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="year"    column="year"    />
        <result property="status"    column="status"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectBusiGradeVo">
        select id, name, year, status, update_time from b_busi_grade
    </sql>

    <select id="selectBusiGradeList" parameterType="BusiGrade" resultMap="BusiGradeResult">
        <include refid="selectBusiGradeVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="year != null "> and year = #{year}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectBusiGradeById" parameterType="Long" resultMap="BusiGradeResult">
        <include refid="selectBusiGradeVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBusiGrade" parameterType="BusiGrade" useGeneratedKeys="true" keyProperty="id">
        insert into b_busi_grade
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">name,</if>
            <if test="year != null">year,</if>
            <if test="status != null">status,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">#{name},</if>
            <if test="year != null">#{year},</if>
            <if test="status != null">#{status},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateBusiGrade" parameterType="BusiGrade">
        update b_busi_grade
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="year != null">year = #{year},</if>
            <if test="status != null">status = #{status},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBusiGradeById" parameterType="Long">
        delete from b_busi_grade where id = #{id}
    </delete>

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