<?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.ie.mapper.AEnrollUniversityMapper">
    
    <resultMap type="AEnrollUniversity" id="AEnrollUniversityResult">
        <result property="id"    column="id"    />
        <result property="year"    column="year"    />
        <result property="universityId"    column="universityId"    />
        <result property="universityName"    column="universityName"    />
        <result property="enrollFormula"    column="enrollFormula"    />
        <result property="majorGroups"    column="majorGroups"    />
        <result property="majorNames"    column="majorNames"    />
        <result property="examineeTypes"    column="examineeTypes"    />
        <result property="typeChange"    column="typeChange"    />
    </resultMap>

    <sql id="selectAEnrollUniversityVo">
        select id, year, universityId, universityName, enrollFormula, majorGroups, majorNames, examineeTypes, typeChange from a_enroll_university
    </sql>

    <select id="selectAEnrollUniversityList" parameterType="AEnrollUniversity" resultMap="AEnrollUniversityResult">
        <include refid="selectAEnrollUniversityVo"/>
        <where>  
            <if test="year != null "> and year = #{year}</if>
            <if test="universityId != null "> and universityId = #{universityId}</if>
            <if test="universityName != null  and universityName != ''"> and universityName like concat('%', #{universityName}, '%')</if>
            <if test="enrollFormula != null  and enrollFormula != ''"> and enrollFormula = #{enrollFormula}</if>
            <if test="majorGroups != null  and majorGroups != ''"> and majorGroups = #{majorGroups}</if>
            <if test="majorNames != null  and majorNames != ''"> and majorNames = #{majorNames}</if>
            <if test="examineeTypes != null  and examineeTypes != ''"> and examineeTypes = #{examineeTypes}</if>
            <if test="typeChange != null "> and typeChange = #{typeChange}</if>
        </where>
    </select>
    
    <select id="selectAEnrollUniversityById" parameterType="Long" resultMap="AEnrollUniversityResult">
        <include refid="selectAEnrollUniversityVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAEnrollUniversity" parameterType="AEnrollUniversity" useGeneratedKeys="true" keyProperty="id">
        insert into a_enroll_university
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="year != null">year,</if>
            <if test="universityId != null">universityId,</if>
            <if test="universityName != null">universityName,</if>
            <if test="enrollFormula != null">enrollFormula,</if>
            <if test="majorGroups != null">majorGroups,</if>
            <if test="majorNames != null">majorNames,</if>
            <if test="examineeTypes != null">examineeTypes,</if>
            <if test="typeChange != null">typeChange,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="year != null">#{year},</if>
            <if test="universityId != null">#{universityId},</if>
            <if test="universityName != null">#{universityName},</if>
            <if test="enrollFormula != null">#{enrollFormula},</if>
            <if test="majorGroups != null">#{majorGroups},</if>
            <if test="majorNames != null">#{majorNames},</if>
            <if test="examineeTypes != null">#{examineeTypes},</if>
            <if test="typeChange != null">#{typeChange},</if>
         </trim>
    </insert>

    <update id="updateAEnrollUniversity" parameterType="AEnrollUniversity">
        update a_enroll_university
        <trim prefix="SET" suffixOverrides=",">
            <if test="year != null">year = #{year},</if>
            <if test="universityId != null">universityId = #{universityId},</if>
            <if test="universityName != null">universityName = #{universityName},</if>
            <if test="enrollFormula != null">enrollFormula = #{enrollFormula},</if>
            <if test="majorGroups != null">majorGroups = #{majorGroups},</if>
            <if test="majorNames != null">majorNames = #{majorNames},</if>
            <if test="examineeTypes != null">examineeTypes = #{examineeTypes},</if>
            <if test="typeChange != null">typeChange = #{typeChange},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAEnrollUniversityById" parameterType="Long">
        delete from a_enroll_university where id = #{id}
    </delete>

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