<?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.LearnPaperRealMapper">
    
    <resultMap type="LearnPaperReal" id="LearnPaperRealResult">
        <result property="id"    column="id"    />
        <result property="subjectId"    column="subjectId"    />
        <result property="paperName"    column="paperName"    />
        <result property="year"    column="year"    />
        <result property="paperType"    column="paperType"    />
        <result property="number"    column="number"    />
        <result property="fenshu"    column="fenshu"    />
        <result property="paperSource"    column="paperSource"    />
        <result property="online"    column="online"    />
        <result property="tiid"    column="tiid"    />
        <result property="osspath"    column="osspath"    />
        <result property="filename"    column="filename"    />
        <result property="locations"    column="locations"    />
        <result property="examineeType"    column="examineeType"    />
        <result property="createTime"    column="createTime"    />
    </resultMap>

    <sql id="selectLearnPaperRealVo">
        select id, subjectId, paperName, year, paperType, number, fenshu, paperSource, online, tiid, osspath, filename, locations, examineeType, createTime from learn_paper_real
    </sql>

    <select id="selectLearnPaperRealList" parameterType="LearnPaperReal" resultMap="LearnPaperRealResult">
        <include refid="selectLearnPaperRealVo"/>
        <where>  
            <if test="subjectId != null "> and subjectId = #{subjectId}</if>
            <if test="paperName != null  and paperName != ''"> and paperName like concat('%', #{paperName}, '%')</if>
            <if test="year != null "> and year = #{year}</if>
            <if test="paperType != null  and paperType != ''"> and paperType = #{paperType}</if>
            <if test="number != null  and number != ''"> and number = #{number}</if>
            <if test="fenshu != null "> and fenshu = #{fenshu}</if>
            <if test="paperSource != null "> and paperSource = #{paperSource}</if>
            <if test="online != null "> and online = #{online}</if>
            <if test="tiid != null  and tiid != ''"> and tiid = #{tiid}</if>
            <if test="osspath != null  and osspath != ''"> and osspath = #{osspath}</if>
            <if test="filename != null  and filename != ''"> and filename like concat('%', #{filename}, '%')</if>
            <if test="locations != null  and locations != ''"> and locations = #{locations}</if>
            <if test="examineeType != null  and examineeType != ''"> and examineeType = #{examineeType}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
        </where>
    </select>
    
    <select id="selectLearnPaperRealById" parameterType="Long" resultMap="LearnPaperRealResult">
        <include refid="selectLearnPaperRealVo"/>
        where id = #{id}
    </select>

    <insert id="insertLearnPaperReal" parameterType="LearnPaperReal" useGeneratedKeys="true" keyProperty="id">
        insert into learn_paper_real
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="subjectId != null">subjectId,</if>
            <if test="paperName != null and paperName != ''">paperName,</if>
            <if test="year != null">year,</if>
            <if test="paperType != null">paperType,</if>
            <if test="number != null">number,</if>
            <if test="fenshu != null">fenshu,</if>
            <if test="paperSource != null">paperSource,</if>
            <if test="online != null">online,</if>
            <if test="tiid != null">tiid,</if>
            <if test="osspath != null">osspath,</if>
            <if test="filename != null">filename,</if>
            <if test="locations != null and locations != ''">locations,</if>
            <if test="examineeType != null and examineeType != ''">examineeType,</if>
            <if test="createTime != null">createTime,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="subjectId != null">#{subjectId},</if>
            <if test="paperName != null and paperName != ''">#{paperName},</if>
            <if test="year != null">#{year},</if>
            <if test="paperType != null">#{paperType},</if>
            <if test="number != null">#{number},</if>
            <if test="fenshu != null">#{fenshu},</if>
            <if test="paperSource != null">#{paperSource},</if>
            <if test="online != null">#{online},</if>
            <if test="tiid != null">#{tiid},</if>
            <if test="osspath != null">#{osspath},</if>
            <if test="filename != null">#{filename},</if>
            <if test="locations != null and locations != ''">#{locations},</if>
            <if test="examineeType != null and examineeType != ''">#{examineeType},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateLearnPaperReal" parameterType="LearnPaperReal">
        update learn_paper_real
        <trim prefix="SET" suffixOverrides=",">
            <if test="subjectId != null">subjectId = #{subjectId},</if>
            <if test="paperName != null and paperName != ''">paperName = #{paperName},</if>
            <if test="year != null">year = #{year},</if>
            <if test="paperType != null">paperType = #{paperType},</if>
            <if test="number != null">number = #{number},</if>
            <if test="fenshu != null">fenshu = #{fenshu},</if>
            <if test="paperSource != null">paperSource = #{paperSource},</if>
            <if test="online != null">online = #{online},</if>
            <if test="tiid != null">tiid = #{tiid},</if>
            <if test="osspath != null">osspath = #{osspath},</if>
            <if test="filename != null">filename = #{filename},</if>
            <if test="locations != null and locations != ''">locations = #{locations},</if>
            <if test="examineeType != null and examineeType != ''">examineeType = #{examineeType},</if>
            <if test="createTime != null">createTime = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteLearnPaperRealById" parameterType="Long">
        delete from learn_paper_real where id = #{id}
    </delete>

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