<?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.AMarjorEnrollMapper">
    
    <resultMap type="AMarjorEnroll" id="AMarjorEnrollResult">
        <result property="id"    column="id"    />
        <result property="year"    column="year"    />
        <result property="universityId"    column="universityId"    />
        <result property="universityName"    column="universityName"    />
        <result property="majorGroup"    column="majorGroup"    />
        <result property="majorName"    column="majorName"    />
        <result property="majorDirection"    column="majorDirection"    />
        <result property="enrollTotal"    column="enrollTotal"    />
        <result property="addedTotal"    column="addedTotal"    />
        <result property="twoTotal"    column="twoTotal"    />
        <result property="threeTotal"    column="threeTotal"    />
    </resultMap>

    <sql id="selectAMarjorEnrollVo">
        select id, year, universityId, universityName, majorGroup, majorName, majorDirection, enrollTotal, addedTotal, twoTotal, threeTotal from a_marjor_enroll
    </sql>

    <select id="selectAMarjorEnrollList" parameterType="AMarjorEnroll" resultMap="AMarjorEnrollResult">
        <include refid="selectAMarjorEnrollVo"/>
        <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="majorGroup != null  and majorGroup != ''"> and majorGroup = #{majorGroup}</if>
            <if test="majorName != null  and majorName != ''"> and majorName like concat('%', #{majorName}, '%')</if>
            <if test="majorDirection != null  and majorDirection != ''"> and majorDirection = #{majorDirection}</if>
            <if test="enrollTotal != null "> and enrollTotal = #{enrollTotal}</if>
            <if test="addedTotal != null "> and addedTotal = #{addedTotal}</if>
            <if test="twoTotal != null "> and twoTotal = #{twoTotal}</if>
            <if test="threeTotal != null "> and threeTotal = #{threeTotal}</if>
        </where>
    </select>
    
    <select id="selectAMarjorEnrollById" parameterType="Long" resultMap="AMarjorEnrollResult">
        <include refid="selectAMarjorEnrollVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAMarjorEnroll" parameterType="AMarjorEnroll" useGeneratedKeys="true" keyProperty="id">
        insert into a_marjor_enroll
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="year != null">year,</if>
            <if test="universityId != null">universityId,</if>
            <if test="universityName != null">universityName,</if>
            <if test="majorGroup != null">majorGroup,</if>
            <if test="majorName != null">majorName,</if>
            <if test="majorDirection != null">majorDirection,</if>
            <if test="enrollTotal != null">enrollTotal,</if>
            <if test="addedTotal != null">addedTotal,</if>
            <if test="twoTotal != null">twoTotal,</if>
            <if test="threeTotal != null">threeTotal,</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="majorGroup != null">#{majorGroup},</if>
            <if test="majorName != null">#{majorName},</if>
            <if test="majorDirection != null">#{majorDirection},</if>
            <if test="enrollTotal != null">#{enrollTotal},</if>
            <if test="addedTotal != null">#{addedTotal},</if>
            <if test="twoTotal != null">#{twoTotal},</if>
            <if test="threeTotal != null">#{threeTotal},</if>
         </trim>
    </insert>

    <update id="updateAMarjorEnroll" parameterType="AMarjorEnroll">
        update a_marjor_enroll
        <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="majorGroup != null">majorGroup = #{majorGroup},</if>
            <if test="majorName != null">majorName = #{majorName},</if>
            <if test="majorDirection != null">majorDirection = #{majorDirection},</if>
            <if test="enrollTotal != null">enrollTotal = #{enrollTotal},</if>
            <if test="addedTotal != null">addedTotal = #{addedTotal},</if>
            <if test="twoTotal != null">twoTotal = #{twoTotal},</if>
            <if test="threeTotal != null">threeTotal = #{threeTotal},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAMarjorEnrollById" parameterType="Long">
        delete from a_marjor_enroll where id = #{id}
    </delete>

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