<?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.learn.mapper.LearnDirectedKnowledgeMapper">
    
    <resultMap type="LearnDirectedKnowledge" id="LearnDirectedKnowledgeResult">
        <result property="id"    column="id"    />
        <result property="year"    column="year"    />
        <result property="universityId"    column="university_id"    />
        <result property="directKey"    column="direct_key"    />
        <result property="enrollFormula"    column="enrollFormula"    />
        <result property="cultural"    column="cultural"    />
        <result property="professional"    column="professional"    />
        <result property="subjects"    column="subjects"    />
        <result property="questionTypes"    column="question_types"    />
        <result property="knowledges"    column="knowledges"    />
        <result property="locations"    column="locations"    />
        <result property="examineeTypes"    column="examineeTypes"    />
        <result property="conditions"    column="conditions"    />
    </resultMap>

    <sql id="selectLearnDirectedKnowledgeVo">
        select id, year, university_id, direct_key, enrollFormula, cultural, professional, subjects, question_types, knowledges, locations, examineeTypes, conditions from learn_directed_knowledge
    </sql>

    <select id="selectLearnDirectedKnowledgeList" parameterType="LearnDirectedKnowledge" resultMap="LearnDirectedKnowledgeResult">
        <include refid="selectLearnDirectedKnowledgeVo"/>
        <where>  
            <if test="year != null "> and year = #{year}</if>
            <if test="universityId != null  and universityId != ''"> and university_id = #{universityId}</if>
            <if test="directKey != null  and directKey != ''"> and direct_key = #{directKey}</if>
            <if test="enrollFormula != null  and enrollFormula != ''"> and enrollFormula = #{enrollFormula}</if>
            <if test="cultural != null  and cultural != ''"> and cultural = #{cultural}</if>
            <if test="professional != null  and professional != ''"> and professional = #{professional}</if>
            <if test="subjects != null  and subjects != ''"> and subjects = #{subjects}</if>
            <if test="questionTypes != null  and questionTypes != ''"> and question_types = #{questionTypes}</if>
            <if test="knowledges != null  and knowledges != ''"> and knowledges = #{knowledges}</if>
            <if test="locations != null  and locations != ''"> and locations = #{locations}</if>
            <if test="examineeTypes != null  and examineeTypes != ''"> and examineeTypes = #{examineeTypes}</if>
            <if test="conditions != null  and conditions != ''"> and conditions = #{conditions}</if>
        </where>
    </select>
    
    <select id="selectLearnDirectedKnowledgeById" parameterType="Long" resultMap="LearnDirectedKnowledgeResult">
        <include refid="selectLearnDirectedKnowledgeVo"/>
        where id = #{id}
    </select>

    <select id="selectByUniversityIds" parameterType="Long" resultMap="LearnDirectedKnowledgeResult">
        <include refid="selectLearnDirectedKnowledgeVo"/>
        where id in <foreach item="id" collection="array" open="(" separator="," close=")">#{id}</foreach>
    </select>

    <insert id="insertLearnDirectedKnowledge" parameterType="LearnDirectedKnowledge" useGeneratedKeys="true" keyProperty="id">
        insert into learn_directed_knowledge
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="year != null">year,</if>
            <if test="universityId != null">university_id,</if>
            <if test="directKey != null">direct_key,</if>
            <if test="enrollFormula != null">enrollFormula,</if>
            <if test="cultural != null">cultural,</if>
            <if test="professional != null">professional,</if>
            <if test="subjects != null">subjects,</if>
            <if test="questionTypes != null">question_types,</if>
            <if test="knowledges != null">knowledges,</if>
            <if test="locations != null">locations,</if>
            <if test="examineeTypes != null">examineeTypes,</if>
            <if test="conditions != null">conditions,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="year != null">#{year},</if>
            <if test="universityId != null">#{universityId},</if>
            <if test="directKey != null">#{directKey},</if>
            <if test="enrollFormula != null">#{enrollFormula},</if>
            <if test="cultural != null">#{cultural},</if>
            <if test="professional != null">#{professional},</if>
            <if test="subjects != null">#{subjects},</if>
            <if test="questionTypes != null">#{questionTypes},</if>
            <if test="knowledges != null">#{knowledges},</if>
            <if test="locations != null">#{locations},</if>
            <if test="examineeTypes != null">#{examineeTypes},</if>
            <if test="conditions != null">#{conditions},</if>
         </trim>
    </insert>

    <update id="updateLearnDirectedKnowledge" parameterType="LearnDirectedKnowledge">
        update learn_directed_knowledge
        <trim prefix="SET" suffixOverrides=",">
            <if test="year != null">year = #{year},</if>
            <if test="universityId != null">university_id = #{universityId},</if>
            <if test="directKey != null">direct_key = #{directKey},</if>
            <if test="enrollFormula != null">enrollFormula = #{enrollFormula},</if>
            <if test="cultural != null">cultural = #{cultural},</if>
            <if test="professional != null">professional = #{professional},</if>
            <if test="subjects != null">subjects = #{subjects},</if>
            <if test="questionTypes != null">question_types = #{questionTypes},</if>
            <if test="knowledges != null">knowledges = #{knowledges},</if>
            <if test="locations != null">locations = #{locations},</if>
            <if test="examineeTypes != null">examineeTypes = #{examineeTypes},</if>
            <if test="conditions != null">conditions = #{conditions},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteLearnDirectedKnowledgeById" parameterType="Long">
        delete from learn_directed_knowledge where id = #{id}
    </delete>

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