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

    <resultMap type="BusiWishUniversitySubmitPreRecruitPlan" id="BusiWishUniversitySubmitPreRecruitPlanResult">
        <result property="id"    column="id"    />
        <result property="tag"    column="tag"    />
        <result property="tagCode"    column="tagCode"    />
        <result property="collegeCode"    column="collegeCode"    />
        <result property="category"    column="category"    />
        <result property="year"    column="year"    />
        <result property="location"    column="location"    />
        <result property="level"    column="level"    />
        <result property="course"    column="course"    />
        <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="premark"    column="premark"    />
        <result property="groups"    column="groups"    />
        <result property="groupsName"    column="groupsName"    />
        <result property="planCount"    column="planCount"    />
        <result property="xuefei"    column="xuefei"    />
        <result property="xuezhi"    column="xuezhi"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="createTime"    />
        <result property="udid"    column="udid"    />
        <result property="pudid"    column="pudid"    />
        <result property="dataType"    column="dataType"    />
    </resultMap>

    <sql id="selectBusiWishUniversitySubmitPreRecruitPlanVo">
        select udid, pudid, dataType, id, tag, tagCode, collegeCode, category, year, location, level, course,course0,course1,course2, universityId, universityCode, universityName, marjorCode, marjorName, marjorBelongs, marjorDirection, premark, `groups`, groupsName, planCount, xuefei, xuezhi, status, createTime from b_busi_wish_university_submit_pre_recruit_plan
    </sql>

    <select id="selectBusiWishUniversitySubmitPreRecruitPlanList" parameterType="BusiWishUniversitySubmitPreRecruitPlan" resultMap="BusiWishUniversitySubmitPreRecruitPlanResult">
        <include refid="selectBusiWishUniversitySubmitPreRecruitPlanVo"/>
        <where>
            <if test="dataType != null  and dataType != ''"> and dataType = #{dataType}</if>
            <if test="tag != null  and tag != ''"> and tag like concat('%',#{tag},'%') </if>
            <if test="tagCode != null  and tagCode != ''"> and tagCode like concat( #{tagCode},'%')</if>
            <if test="collegeCode != null  and collegeCode != ''"> and collegeCode = #{collegeCode}</if>
            <if test="category != null  and category != ''"> and category = #{category}</if>
            <if test="year != null  and year != ''"> and year = #{year}</if>
            <if test="location != null  and location != ''"> and location = #{location}</if>
            <if test="level != null  and level != ''"> and level = #{level}</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="course2 != null  and course2 != ''"> and course2 = #{course2}</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="premark != null  and premark != ''"> and premark = #{premark}</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="planCount != null  and planCount != ''"> and planCount = #{planCount}</if>
            <if test="xuefei != null  and xuefei != ''"> and xuefei = #{xuefei}</if>
            <if test="xuezhi != null  and xuezhi != ''"> and xuezhi = #{xuezhi}</if>
            <if test="status != null "> and status = #{status}</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="types" resultType="String">
        select distinct course0 from b_busi_wish_university_submit_pre_recruit_plan where status &gt; 0 and course0 is not null
        <if test="location!=null and location!=''">
            and location = #{location}
        </if>
        <if test="year!=null">
            and year = #{year}
        </if>
    </select>

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

    <select id="getTags" resultType="String">
        select distinct tag from b_busi_wish_university_submit_pre_recruit_plan where status &gt; 0 and tag is not null
        <if test="location!=null and location!=''">
            and location = #{location}
        </if>
        <if test="year!=null">
            and year = #{year}
        </if>
    </select>

    <select id="selectBusiWishUniversitySubmitPreRecruitPlanById" parameterType="Long" resultMap="BusiWishUniversitySubmitPreRecruitPlanResult">
        <include refid="selectBusiWishUniversitySubmitPreRecruitPlanVo"/>
        where id = #{id}
    </select>

    <insert id="insertBusiWishUniversitySubmitPreRecruitPlan" parameterType="BusiWishUniversitySubmitPreRecruitPlan" useGeneratedKeys="true" keyProperty="id">
        insert into b_busi_wish_university_submit_pre_recruit_plan
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="tag != null">tag,</if>
            <if test="tagCode != null">tagCode,</if>
            <if test="collegeCode != null">collegeCode,</if>
            <if test="category != null and category != ''">category,</if>
            <if test="year != null and year != ''">year,</if>
            <if test="location != null and location != ''">location,</if>
            <if test="level != null">level,</if>
            <if test="course != null">course,</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="premark != null">premark,</if>
            <if test="groups != null">`groups`,</if>
            <if test="groupsName != null">groupsName,</if>
            <if test="planCount != null">planCount,</if>
            <if test="xuefei != null">xuefei,</if>
            <if test="xuezhi != null">xuezhi,</if>
            <if test="status != null">status,</if>
            <if test="createTime != null">createTime,</if>
            <if test="dataType != null">dataType,</if>
<!--            <if test="udid != null and udid != ''">udid,</if>-->
<!--            <if test="pudid != null">pudid,</if>-->
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="tag != null">#{tag},</if>
            <if test="tagCode != null">#{tagCode},</if>
            <if test="collegeCode != null">#{collegeCode},</if>
            <if test="category != null and category != ''">#{category},</if>
            <if test="year != null and year != ''">#{year},</if>
            <if test="location != null and location != ''">#{location},</if>
            <if test="level != null">#{level},</if>
            <if test="course != null">#{course},</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="premark != null">#{premark},</if>
            <if test="groups != null">#{groups},</if>
            <if test="groupsName != null">#{groupsName},</if>
            <if test="planCount != null">#{planCount},</if>
            <if test="xuefei != null">#{xuefei},</if>
            <if test="xuezhi != null">#{xuezhi},</if>
            <if test="status != null">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="dataType != null">#{dataType},</if>
<!--            <if test="udid != null and udid != ''">#{udid},</if>-->
<!--            <if test="pudid != null">#{pudid},</if>-->
        </trim>
    </insert>

    <update id="updateBusiWishUniversitySubmitPreRecruitPlanTagCode" parameterType="BusiWishUniversitySubmitPreRecruitPlan">
        update b_busi_wish_university_submit_pre_recruit_plan set tagCode = #{tagCode} where tag = #{tag}
    </update>

    <update id="updateBusiWishUniversitySubmitPreRecruitPlan" parameterType="BusiWishUniversitySubmitPreRecruitPlan">
        update b_busi_wish_university_submit_pre_recruit_plan
        <trim prefix="SET" suffixOverrides=",">
            <if test="tag != null">tag = #{tag},</if>
            <if test="tagCode != null">tag = #{tagCode},</if>
            <if test="collegeCode != null">collegeCode = #{collegeCode},</if>
            <if test="category != null and category != ''">category = #{category},</if>
            <if test="year != null and year != ''">year = #{year},</if>
            <if test="location != null and location != ''">location = #{location},</if>
            <if test="level != null">level = #{level},</if>
            <if test="course != null">course = #{course},</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="premark != null">premark = #{premark},</if>
            <if test="groups != null">`groups` = #{groups},</if>
            <if test="groupsName != null">groupsName = #{groupsName},</if>
            <if test="planCount != null">planCount = #{planCount},</if>
            <if test="xuefei != null">xuefei = #{xuefei},</if>
            <if test="xuezhi != null">xuezhi = #{xuezhi},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createTime != null">createTime = #{createTime},</if>
<!--            <if test="udid != null and udid != ''">udid = #{udid},</if>-->
--             <if test="pudid != null">pudid = #{pudid},</if>
            <if test="dataType != null">dataType = #{dataType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBusiWishUniversitySubmitPreRecruitPlanById" parameterType="Long">
        delete from b_busi_wish_university_submit_pre_recruit_plan where id = #{id}
    </delete>

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