<?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.srs.flowable.mapper.DisMateMapper">
    
    <resultMap type="DisMate" id="SysDisMateResult">
        <result property="id"    column="id"    />
        <result property="stId"    column="st_id"    />
        <result property="stName"    column="st_name"    />
        <result property="times"    column="times"    />
        <result property="college"    column="college"    />
        <result property="oldgrade"    column="oldgrade"    />
        <result property="oldmajor"    column="oldmajor"    />
        <result property="newgrade"    column="newgrade"    />
        <result property="newmajor"    column="newmajor"    />
        <result property="proof"    column="proof"    />
        <result property="idcard"    column="idcard"    />
        <result property="material"    column="material"    />
        <result property="data1"    column="data1"    />
        <result property="data2"    column="data2"    />
    </resultMap>

    <sql id="selectSysDisMateVo">
        select id, st_id, st_name, times, college, oldgrade, oldmajor, newgrade, newmajor, proof, idcard, material, data1, data2 from sys_dis_mate
    </sql>

    <select id="selectSysDisMateList" parameterType="SysDisMate" resultMap="SysDisMateResult">
        <include refid="selectSysDisMateVo"/>
        <where>  
            <if test="stId != null  and stId != ''"> and st_id = #{stId}</if>
            <if test="stName != null  and stName != ''"> and st_name like concat('%', #{stName}, '%')</if>
            <if test="times != null  and times != ''"> and times = #{times}</if>
            <if test="college != null  and college != ''"> and college = #{college}</if>
            <if test="oldgrade != null  and oldgrade != ''"> and oldgrade = #{oldgrade}</if>
            <if test="oldmajor != null  and oldmajor != ''"> and oldmajor = #{oldmajor}</if>
            <if test="newgrade != null  and newgrade != ''"> and newgrade = #{newgrade}</if>
            <if test="newmajor != null  and newmajor != ''"> and newmajor = #{newmajor}</if>
            <if test="proof != null  and proof != ''"> and proof = #{proof}</if>
            <if test="idcard != null  and idcard != ''"> and idcard = #{idcard}</if>
            <if test="material != null  and material != ''"> and material = #{material}</if>
            <if test="data1 != null  and data1 != ''"> and data1 = #{data1}</if>
            <if test="data2 != null  and data2 != ''"> and data2 = #{data2}</if>
        </where>
    </select>
    
    <select id="selectSysDisMateById" parameterType="Long" resultMap="SysDisMateResult">
        <include refid="selectSysDisMateVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSysDisMate" parameterType="SysDisMate" useGeneratedKeys="true" keyProperty="id">
        insert into sys_dis_mate
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stId != null">st_id,</if>
            <if test="stName != null">st_name,</if>
            <if test="times != null">times,</if>
            <if test="college != null">college,</if>
            <if test="oldgrade != null">oldgrade,</if>
            <if test="oldmajor != null">oldmajor,</if>
            <if test="newgrade != null">newgrade,</if>
            <if test="newmajor != null">newmajor,</if>
            <if test="proof != null">proof,</if>
            <if test="idcard != null">idcard,</if>
            <if test="material != null">material,</if>
            <if test="data1 != null">data1,</if>
            <if test="data2 != null">data2,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="stId != null">#{stId},</if>
            <if test="stName != null">#{stName},</if>
            <if test="times != null">#{times},</if>
            <if test="college != null">#{college},</if>
            <if test="oldgrade != null">#{oldgrade},</if>
            <if test="oldmajor != null">#{oldmajor},</if>
            <if test="newgrade != null">#{newgrade},</if>
            <if test="newmajor != null">#{newmajor},</if>
            <if test="proof != null">#{proof},</if>
            <if test="idcard != null">#{idcard},</if>
            <if test="material != null">#{material},</if>
            <if test="data1 != null">#{data1},</if>
            <if test="data2 != null">#{data2},</if>
         </trim>
    </insert>

    <update id="updateSysDisMate" parameterType="SysDisMate">
        update sys_dis_mate
        <trim prefix="SET" suffixOverrides=",">
            <if test="stId != null">st_id = #{stId},</if>
            <if test="stName != null">st_name = #{stName},</if>
            <if test="times != null">times = #{times},</if>
            <if test="college != null">college = #{college},</if>
            <if test="oldgrade != null">oldgrade = #{oldgrade},</if>
            <if test="oldmajor != null">oldmajor = #{oldmajor},</if>
            <if test="newgrade != null">newgrade = #{newgrade},</if>
            <if test="newmajor != null">newmajor = #{newmajor},</if>
            <if test="proof != null">proof = #{proof},</if>
            <if test="idcard != null">idcard = #{idcard},</if>
            <if test="material != null">material = #{material},</if>
            <if test="data1 != null">data1 = #{data1},</if>
            <if test="data2 != null">data2 = #{data2},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysDisMateById" parameterType="Long">
        delete from sys_dis_mate where id = #{id}
    </delete>

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