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

    <resultMap type="BusiWishUniversitySubmitPreEnroll" id="BusiWishUniversitySubmitPreEnrollResult">
        <result property="id"    column="id"    />
        <result property="tag"    column="tag"    />
        <result property="subTag"    column="subTag"    />
        <result property="source"    column="source"    />
        <result property="collegeCode"    column="collegeCode"    />
        <result property="year"    column="year"    />
        <result property="location"    column="location"    />
        <result property="universityId"    column="universityId"    />
        <result property="universityCode"    column="universityCode"    />
        <result property="universityName"    column="universityName"    />
        <result property="marjorCode"    column="marjorCode"    />
        <result property="marjorName"    column="marjorName"    />
        <result property="marjorBelongs"    column="marjorBelongs"    />
        <result property="marjorDirection"    column="marjorDirection"    />
        <result property="course"    column="course"    />
        <result property="course0"    column="course0"    />
        <result property="course1"    column="course1"    />
        <result property="groups"    column="groups"    />
        <result property="groupsName"    column="groupsName"    />
        <result property="udid"    column="udid"    />
        <result property="pudid"    column="pudid"    />
        <result property="dataType"    column="dataType"    />
        <result property="score"    column="score"    />
        <result property="seat"    column="seat"    />
        <result property="scoreRealTop"    column="scoreRealTop"    />
        <result property="seatRealTop"    column="seatRealTop"    />
        <result property="num"    column="num"    />
        <result property="numReal"    column="numReal"    />
        <result property="status"    column="status"    />
        <result property="category"    column="category"    />
        <result property="createTime"    column="createTime"    />
    </resultMap>

    <sql id="selectBusiWishUniversitySubmitPreEnrollVo">
        select udid, pudid, id, tag,subTag,  source, collegeCode, year, location, universityId, universityCode, universityName, marjorCode, marjorName, marjorBelongs, marjorDirection, course, course0 ,course1, `groups`, groupsName, dataType, score, seat, scoreRealTop, seatRealTop, num, numReal, status, category, createTime from b_busi_wish_university_submit_pre_enroll
    </sql>

    <select id="selectBusiWishUniversitySubmitPreEnrollList" parameterType="BusiWishUniversitySubmitPreEnroll" resultMap="BusiWishUniversitySubmitPreEnrollResult">
        <include refid="selectBusiWishUniversitySubmitPreEnrollVo"/>
        <where>
            <if test="tag != null  and tag != ''"> and tag like concat('%', #{tag},'%')</if>
            <if test="subTag != null  and subTag != ''"> and subTag = #{subTag}</if>
            <if test="source != null  and source != ''"> and source = #{source}</if>
            <if test="collegeCode != null  and collegeCode != ''"> and collegeCode = #{collegeCode}</if>
            <if test="year != null  and year != ''"> and year = #{year}</if>
            <if test="location != null  and location != ''"> and location = #{location}</if>
            <if test="universityId != null  and universityId != ''"> and universityId = #{universityId}</if>
            <if test="universityCode != null  and universityCode != ''"> and universityCode like concat('%' ,#{universityCode},'%' )</if>
            <if test="universityName != null  and universityName != ''"> and universityName like concat('%', #{universityName}, '%')</if>
            <if test="keyword != null  and keyword != ''">
                and ( universityName like concat('%', #{keyword}, '%')
                or marjorName like concat('%', #{keyword}, '%'))
            </if>
            <if test="marjorCode != null  and marjorCode != ''"> and marjorCode = #{marjorCode}</if>
            <if test="marjorName != null  and marjorName != ''"> and marjorName like concat('%', #{marjorName}, '%')</if>
            <if test="marjorBelongs != null  and marjorBelongs != ''"> and marjorBelongs = #{marjorBelongs}</if>
            <if test="marjorDirection != null  and marjorDirection != ''"> and marjorDirection = #{marjorDirection}</if>
            <if test="course != null  and course != ''"> and course = #{course}</if>
            <if test="course0 != null  and course0 != ''"> and course0 = #{course0}</if>
            <if test="course1 != null  and course1 != ''"> and course1 = #{course1}</if>
            <if test="groups != null  and groups != ''"> and `groups` = #{groups}</if>
            <if test="groupsName != null  and groupsName != ''"> and groupsName like concat('%', #{groupsName}, '%')</if>
            <if test="udid != null  and udid != ''"> and udid = #{udid}</if>
            <if test="pudid != null  and pudid != ''"> and pudid = #{pudid}</if>
            <if test="dataType != null  and dataType != ''"> and dataType = #{dataType}</if>
            <if test="score != null  and score != ''"> and score = #{score}</if>
            <if test="seat != null  and seat != ''"> and seat = #{seat}</if>
            <if test="scoreRealTop != null  and scoreRealTop != ''"> and scoreRealTop = #{scoreRealTop}</if>
            <if test="seatRealTop != null  and seatRealTop != ''"> and seatRealTop = #{seatRealTop}</if>
            <if test="num != null  and num != ''"> and num = #{num}</if>
            <if test="numReal != null  and numReal != ''"> and numReal = #{numReal}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="category != null and category != '' "> and category = #{category}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="pudids != null"> and pudid in <foreach item="pudid" collection="pudids" open="(" separator="," close=")">#{pudid}</foreach></if>
            <if test="udid != null  and udid != ''"> and udid = #{udid}</if>
            <if test="pudid != null  and pudid != ''"> and pudid = #{pudid}</if>
        </where>
        order by universityCode asc
    </select>

    <select id="selectBusiWishUniversitySubmitPreEnrollById" parameterType="Long" resultMap="BusiWishUniversitySubmitPreEnrollResult">
        <include refid="selectBusiWishUniversitySubmitPreEnrollVo"/>
        where id = #{id}
    </select>

    <select id="years" resultType="String">
        select distinct year from b_busi_wish_university_submit_pre_enroll where status &gt; 0 and year is not null
        <if test="location!=null and location!=''">
            and location = #{location}
        </if>
        <if test="category!=null and category!=''">
            and category = #{category}
        </if>
        order by year desc
    </select>

    <select id="getTag" resultType="String">
        select
        <choose>
            <when test="tag!=null and tag!=''">
                distinct subTag
            </when>
            <otherwise>
                distinct tag
            </otherwise>
        </choose>
        from b_busi_wish_university_submit_pre_enroll where status &gt; 0
        <if test="location!=null and location!=''">
            and location = #{location}
        </if>
        <if test="year!=null and year!=''">
            and year = #{year}
        </if>
        <if test="tag!=null and tag!=''">
            and tag like concat ('%',#{tag},'%')
        </if>
        <if test="category!=null and category!=''">
            and category = #{category}
        </if>
        order by tag asc
    </select>

    <select id="getCourse1" resultType="String">
        select
        <choose>
            <when test="course0!=null and course0!=''">
                distinct course1
            </when>
            <otherwise>
                distinct course0
            </otherwise>
        </choose>
        from b_busi_wish_university_submit_pre_enroll where status &gt; 0
        <if test="location!=null and location!=''">
            and location = #{location}
        </if>
        <if test="year!=null and year!=''">
            and year = #{year}
        </if>
        <if test="course0!=null and course0!=''">
            and course0 = #{course0}
        </if>
        <if test="category!=null and category != ''">
            and category = #{category}
        </if>
        <if test="tag!=null and tag!=''">
            and tag like concat('%', #{tag},'%')
        </if>
    </select>

    <insert id="insertBusiWishUniversitySubmitPreEnroll" parameterType="BusiWishUniversitySubmitPreEnroll" useGeneratedKeys="true" keyProperty="id">
        insert into b_busi_wish_university_submit_pre_enroll
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="tag != null">tag,</if>
            <if test="subTag != null">subTag,</if>
            <if test="source != null">source,</if>
            <if test="collegeCode != null">collegeCode,</if>
            <if test="year != null and year != ''">year,</if>
            <if test="location != null and location != ''">location,</if>
            <if test="universityId != null">universityId,</if>
            <if test="universityCode != null">universityCode,</if>
            <if test="universityName != null">universityName,</if>
            <if test="marjorCode != null">marjorCode,</if>
            <if test="marjorName != null">marjorName,</if>
            <if test="marjorBelongs != null">marjorBelongs,</if>
            <if test="marjorDirection != null">marjorDirection,</if>
            <if test="course != null">course,</if>
            <if test="course0 != null">course0,</if>
            <if test="course1 != null">course1,</if>
            <if test="groups != null">`groups`,</if>
            <if test="groupsName != null">groupsName,</if>
            <if test="udid != null and udid != ''">udid,</if>
            <if test="pudid != null">pudid,</if>
            <if test="dataType != null">dataType,</if>
            <if test="score != null">score,</if>
            <if test="seat != null">seat,</if>
            <if test="scoreRealTop != null">scoreRealTop,</if>
            <if test="seatRealTop != null">seatRealTop,</if>
            <if test="num != null">num,</if>
            <if test="numReal != null">numReal,</if>
            <if test="status != null">status,</if>
            <if test="category != null and category != ''">category,</if>
            <if test="createTime != null">createTime,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="tag != null">#{tag},</if>
            <if test="subTag != null">#{subTag},</if>
            <if test="source != null">#{source},</if>
            <if test="collegeCode != null">#{collegeCode},</if>
            <if test="year != null and year != ''">#{year},</if>
            <if test="location != null and location != ''">#{location},</if>
            <if test="universityId != null">#{universityId},</if>
            <if test="universityCode != null">#{universityCode},</if>
            <if test="universityName != null">#{universityName},</if>
            <if test="marjorCode != null">#{marjorCode},</if>
            <if test="marjorName != null">#{marjorName},</if>
            <if test="marjorBelongs != null">#{marjorBelongs},</if>
            <if test="marjorDirection != null">#{marjorDirection},</if>
            <if test="course != null">#{course},</if>
            <if test="course0 != null">#{course0},</if>
            <if test="course1 != null">#{course1},</if>
            <if test="groups != null">#{groups},</if>
            <if test="groupsName != null">#{groupsName},</if>
            <if test="udid != null and udid != ''">#{udid},</if>
            <if test="pudid != null">#{pudid},</if>
            <if test="dataType != null">#{dataType},</if>
            <if test="score != null">#{score},</if>
            <if test="seat != null">#{seat},</if>
            <if test="scoreRealTop != null">#{scoreRealTop},</if>
            <if test="seatRealTop != null">#{seatRealTop},</if>
            <if test="num != null">#{num},</if>
            <if test="numReal != null">#{numReal},</if>
            <if test="status != null">#{status},</if>
            <if test="category != null and category != ''">#{category},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateBusiWishUniversitySubmitPreEnroll" parameterType="BusiWishUniversitySubmitPreEnroll">
        update b_busi_wish_university_submit_pre_enroll
        <trim prefix="SET" suffixOverrides=",">
            <if test="tag != null">tag = #{tag},</if>
            <if test="subTag != null">subTag = #{subTag},</if>
            <if test="source != null">source = #{source},</if>
            <if test="collegeCode != null">collegeCode = #{collegeCode},</if>
            <if test="year != null and year != ''">year = #{year},</if>
            <if test="location != null and location != ''">location = #{location},</if>
            <if test="universityId != null">universityId = #{universityId},</if>
            <if test="universityCode != null">universityCode = #{universityCode},</if>
            <if test="universityName != null">universityName = #{universityName},</if>
            <if test="marjorCode != null">marjorCode = #{marjorCode},</if>
            <if test="marjorName != null">marjorName = #{marjorName},</if>
            <if test="marjorBelongs != null">marjorBelongs = #{marjorBelongs},</if>
            <if test="marjorDirection != null">marjorDirection = #{marjorDirection},</if>
            <if test="course != null">course = #{course},</if>
            <if test="course0 != null">course0 = #{course0},</if>
            <if test="course1 != null">course1 = #{course1},</if>
            <if test="groups != null">`groups` = #{groups},</if>
            <if test="groupsName != null">groupsName = #{groupsName},</if>
            <if test="udid != null and udid != ''">udid = #{udid},</if>
            <if test="pudid != null">pudid = #{pudid},</if>
            <if test="dataType != null">dataType = #{dataType},</if>
            <if test="score != null">score = #{score},</if>
            <if test="seat != null">seat = #{seat},</if>
            <if test="scoreRealTop != null">scoreRealTop = #{scoreRealTop},</if>
            <if test="seatRealTop != null">seatRealTop = #{seatRealTop},</if>
            <if test="num != null">num = #{num},</if>
            <if test="numReal != null">numReal = #{numReal},</if>
            <if test="status != null">status = #{status},</if>
            <if test="category != null and category != ''">category = #{category},</if>
            <if test="createTime != null">createTime = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBusiWishUniversitySubmitPreEnrollById" parameterType="Long">
        delete from b_busi_wish_university_submit_pre_enroll where id = #{id}
    </delete>

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