TTrainCourseTopicMapper.xml 4.48 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3 4 5
<?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">
6

耿迪迪's avatar
耿迪迪 committed
7 8 9 10 11 12 13
    <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"    />
14
        <result property="topicType"    column="topic_type"    />
耿迪迪's avatar
耿迪迪 committed
15 16 17
    </resultMap>

    <sql id="selectTTrainCourseTopicVo">
18
        select topic_id, course_id, topic_title, topic_option, answer, create_time,topic_type from t_train_course_topic
耿迪迪's avatar
耿迪迪 committed
19 20 21 22
    </sql>

    <select id="selectTTrainCourseTopicList" parameterType="TTrainCourseTopic" resultMap="TTrainCourseTopicResult">
        <include refid="selectTTrainCourseTopicVo"/>
23
        <where>
耿迪迪's avatar
耿迪迪 committed
24 25 26 27 28 29 30
            <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">
31
                select topic_id, course_id, topic_title, topic_option, answer, create_time,topic_type from t_train_course_topic
耿迪迪's avatar
耿迪迪 committed
32 33 34 35 36 37
        WHERE course_id = #{courseId}
    </select>
    <select id="selectTTrainCourseTopicById" parameterType="Long" resultMap="TTrainCourseTopicResult">
        <include refid="selectTTrainCourseTopicVo"/>
        where topic_id = #{topicId}
    </select>
38

耿迪迪's avatar
耿迪迪 committed
39 40 41 42 43 44 45 46 47
    <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>
48
            <if test="topicType != null">topic_type</if>
耿迪迪's avatar
耿迪迪 committed
49 50 51 52 53 54 55 56
         </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>
57
            <if test="topicType != null">#{topicType},</if>
耿迪迪's avatar
耿迪迪 committed
58 59 60 61 62 63 64 65 66 67 68
         </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>
69
            <if test="topicType != null">topic_type= #{topicType}</if>
耿迪迪's avatar
耿迪迪 committed
70 71 72 73 74 75 76 77 78
        </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">
79
        delete from t_train_course_topic where topic_id in
耿迪迪's avatar
耿迪迪 committed
80 81 82 83
        <foreach item="topicId" collection="array" open="(" separator="," close=")">
            #{topicId}
        </foreach>
    </delete>
84 85

    <insert id="batchInsertTTrainCourseTopic" parameterType="java.util.List">
吴卿华's avatar
吴卿华 committed
86
        insert into t_train_course_topic(course_id,topic_title,topic_option,answer,create_time,topic_type) values
87
        <foreach collection="list" item="topic" index="index" separator="," >
吴卿华's avatar
吴卿华 committed
88
         (#{topic.courseId},#{topic.topicTitle},#{topic.topicOption},#{topic.answer},#{topic.createTime},#{topic.topicType})
89 90
        </foreach>
    </insert>
91
</mapper>