TTrainPersonMapper.xml 5.17 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
<?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.zehong.system.mapper.TTrainPersonMapper">
    
    <resultMap type="TTrainPerson" id="TTrainPersonResult">
        <result property="id"    column="id"    />
        <result property="trainManageId"    column="train_manage_id"    />
        <result property="trainPersonId"    column="train_person_id"    />
        <result property="realityTrainDuration"    column="reality_train_duration"    />
        <result property="isFinish"    column="is_finish"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="isDel"    column="is_del"    />
    </resultMap>

    <sql id="selectTTrainPersonVo">
        SELECT
            person.id,
            person.train_manage_id,
            person.train_person_id,
            person.reality_train_duration,
            person.is_finish,
            person.create_time,
            person.update_time,
            person.remark,
            person.is_del,
            sysu.nick_name as trainPersonName
        FROM
            t_train_person person
        LEFT JOIN sys_user sysu on sysu.user_id = person.train_person_id
    </sql>

    <select id="selectTTrainPersonList" parameterType="TTrainPerson" resultMap="TTrainPersonResult">
        <include refid="selectTTrainPersonVo"/>
        <where>  
            <if test="trainManageId != null "> and person.train_manage_id = #{trainManageId}</if>
            <if test="trainPersonId != null "> and person.train_person_id = #{trainPersonId}</if>
            <if test="realityTrainDuration != null "> and person.reality_train_duration = #{realityTrainDuration}</if>
            <if test="isFinish != null  and isFinish != ''"> and person.is_finish = #{isFinish}</if>
            <if test="isDel != null  and isDel != ''"> and person.is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectTTrainPersonById" parameterType="Long" resultMap="TTrainPersonResult">
        <include refid="selectTTrainPersonVo"/>
        where person.id = #{id}
    </select>
        
    <insert id="insertTTrainPerson" parameterType="TTrainPerson" useGeneratedKeys="true" keyProperty="id">
        insert into t_train_person
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="trainManageId != null">train_manage_id,</if>
            <if test="trainPersonId != null">train_person_id,</if>
            <if test="realityTrainDuration != null">reality_train_duration,</if>
            <if test="isFinish != null">is_finish,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="isDel != null">is_del,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="trainManageId != null">#{trainManageId},</if>
            <if test="trainPersonId != null">#{trainPersonId},</if>
            <if test="realityTrainDuration != null">#{realityTrainDuration},</if>
            <if test="isFinish != null">#{isFinish},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="isDel != null">#{isDel},</if>
         </trim>
    </insert>

    <update id="updateTTrainPerson" parameterType="TTrainPerson">
        update t_train_person
        <trim prefix="SET" suffixOverrides=",">
            <if test="trainManageId != null">train_manage_id = #{trainManageId},</if>
            <if test="trainPersonId != null">train_person_id = #{trainPersonId},</if>
            <if test="realityTrainDuration != null">reality_train_duration = #{realityTrainDuration},</if>
            <if test="isFinish != null">is_finish = #{isFinish},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTTrainPersonById" parameterType="Long">
        delete from t_train_person where id = #{id}
    </delete>

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

    <insert id="batchInsertTTrainPerson">
        INSERT INTO t_train_person(train_manage_id,train_person_id,create_time) VALUES
        <foreach collection="tTrainPeople" separator="," item="item">
            (${trainManageId},${item.trainPersonId},sysdate())
        </foreach>
    </insert>

    <delete id="deleteTTrainPersonByTrainManageId" parameterType="Long">
        delete from t_train_person where train_manage_id = #{trainManageId}
    </delete>
</mapper>