TTrainCourseTopicMapper.xml 3.81 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
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
<?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.TTrainCourseTopicMapper">
    
    <resultMap type="TTrainCourseTopic" id="TTrainCourseTopicResult">
        <result property="topicId"    column="topic_id"    />
        <result property="courseId"    column="course_id"    />
        <result property="topicTitle"    column="topic_title"    />
        <result property="topicOption"    column="topic_option"    />
        <result property="answer"    column="answer"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectTTrainCourseTopicVo">
        select topic_id, course_id, topic_title, topic_option, answer, create_time from t_train_course_topic
    </sql>

    <select id="selectTTrainCourseTopicList" parameterType="TTrainCourseTopic" resultMap="TTrainCourseTopicResult">
        <include refid="selectTTrainCourseTopicVo"/>
        <where>  
            <if test="courseId != null "> and course_id = #{courseId}</if>
            <if test="topicTitle != null  and topicTitle != ''"> and topic_title = #{topicTitle}</if>
            <if test="topicOption != null  and topicOption != ''"> and topic_option = #{topicOption}</if>
            <if test="answer != null "> and answer = #{answer}</if>
        </where>
    </select>
    <select id="selectCourseTopicList" resultMap="TTrainCourseTopicResult">
                select topic_id, course_id, topic_title, topic_option, answer, create_time from t_train_course_topic
        WHERE course_id = #{courseId}
    </select>
    <select id="selectTTrainCourseTopicById" parameterType="Long" resultMap="TTrainCourseTopicResult">
        <include refid="selectTTrainCourseTopicVo"/>
        where topic_id = #{topicId}
    </select>
        
    <insert id="insertTTrainCourseTopic" parameterType="TTrainCourseTopic">
        insert into t_train_course_topic
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="topicId != null">topic_id,</if>
            <if test="courseId != null">course_id,</if>
            <if test="topicTitle != null">topic_title,</if>
            <if test="topicOption != null">topic_option,</if>
            <if test="answer != null">answer,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="topicId != null">#{topicId},</if>
            <if test="courseId != null">#{courseId},</if>
            <if test="topicTitle != null">#{topicTitle},</if>
            <if test="topicOption != null">#{topicOption},</if>
            <if test="answer != null">#{answer},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateTTrainCourseTopic" parameterType="TTrainCourseTopic">
        update t_train_course_topic
        <trim prefix="SET" suffixOverrides=",">
            <if test="courseId != null">course_id = #{courseId},</if>
            <if test="topicTitle != null">topic_title = #{topicTitle},</if>
            <if test="topicOption != null">topic_option = #{topicOption},</if>
            <if test="answer != null">answer = #{answer},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where topic_id = #{topicId}
    </update>

    <delete id="deleteTTrainCourseTopicById" parameterType="Long">
        delete from t_train_course_topic where topic_id = #{topicId}
    </delete>

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