<?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.BBusiWishUniversitiesDepartmentMajorMapper">
    
    <resultMap type="BBusiWishUniversitiesDepartmentMajor" id="BBusiWishUniversitiesDepartmentMajorResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="name"    column="name"    />
        <result property="departmentId"    column="departmentId"    />
        <result property="level"    column="level"    />
        <result property="levelText"    column="levelText"    />
        <result property="collegeCode"    column="collegeCode"    />
        <result property="createTime"    column="createTime"    />
        <result property="updateTime"    column="updateTime"    />
    </resultMap>

    <sql id="selectBBusiWishUniversitiesDepartmentMajorVo">
        select id, code, name, departmentId, level, levelText, collegeCode, createTime, updateTime from b_busi_wish_universities_department_major
    </sql>

    <select id="selectBBusiWishUniversitiesDepartmentMajorList" parameterType="BBusiWishUniversitiesDepartmentMajor" resultMap="BBusiWishUniversitiesDepartmentMajorResult">
        <include refid="selectBBusiWishUniversitiesDepartmentMajorVo"/>
        <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="departmentId != null  and departmentId != ''"> and departmentId = #{departmentId}</if>
            <if test="level != null  and level != ''"> and level = #{level}</if>
            <if test="levelText != null  and levelText != ''"> and levelText = #{levelText}</if>
            <if test="collegeCode != null  and collegeCode != ''"> and collegeCode = #{collegeCode}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="updateTime != null "> and updateTime = #{updateTime}</if>
        </where>
    </select>
    
    <select id="selectBBusiWishUniversitiesDepartmentMajorById" parameterType="String" resultMap="BBusiWishUniversitiesDepartmentMajorResult">
        <include refid="selectBBusiWishUniversitiesDepartmentMajorVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBBusiWishUniversitiesDepartmentMajor" parameterType="BBusiWishUniversitiesDepartmentMajor">
        insert into b_busi_wish_universities_department_major
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="code != null and code != ''">code,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="departmentId != null and departmentId != ''">departmentId,</if>
            <if test="level != null">level,</if>
            <if test="levelText != null">levelText,</if>
            <if test="collegeCode != null and collegeCode != ''">collegeCode,</if>
            <if test="createTime != null">createTime,</if>
            <if test="updateTime != null">updateTime,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="code != null and code != ''">#{code},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="departmentId != null and departmentId != ''">#{departmentId},</if>
            <if test="level != null">#{level},</if>
            <if test="levelText != null">#{levelText},</if>
            <if test="collegeCode != null and collegeCode != ''">#{collegeCode},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateBBusiWishUniversitiesDepartmentMajor" parameterType="BBusiWishUniversitiesDepartmentMajor">
        update b_busi_wish_universities_department_major
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null and code != ''">code = #{code},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="departmentId != null and departmentId != ''">departmentId = #{departmentId},</if>
            <if test="level != null">level = #{level},</if>
            <if test="levelText != null">levelText = #{levelText},</if>
            <if test="collegeCode != null and collegeCode != ''">collegeCode = #{collegeCode},</if>
            <if test="createTime != null">createTime = #{createTime},</if>
            <if test="updateTime != null">updateTime = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBBusiWishUniversitiesDepartmentMajorById" parameterType="String">
        delete from b_busi_wish_universities_department_major where id = #{id}
    </delete>

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