linzhijie
2021-03-08 d26f0e81960986cef39db408440bbc3d0c56a853
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
<?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.ots.project.exam.mapper.TExamPaperQuestionMapper">
    
    <resultMap type="TExamPaperQuestion" id="TExamPaperQuestionResult">
        <result property="paperId"    column="paper_id"    />
        <result property="questionId"    column="question_id"    />
        <result property="permanentId"    column="permanent_id"    />
    </resultMap>
 
    <sql id="selectTExamPaperQuestionVo">
        select paper_id, question_id, permanent_id from t_exam_paper_question
    </sql>
 
    <select id="selectTExamPaperQuestionList" parameterType="TExamPaperQuestion" resultMap="TExamPaperQuestionResult">
        <include refid="selectTExamPaperQuestionVo"/>
        <where>  
            <if test="questionId != null "> and question_id = #{questionId}</if>
            <if test="permanentId != null  and permanentId != ''"> and permanent_id = #{permanentId}</if>
        </where>
    </select>
    
    <select id="selectTExamPaperQuestionById" parameterType="Long" resultMap="TExamPaperQuestionResult">
        <include refid="selectTExamPaperQuestionVo"/>
        where paper_id = #{paperId}
    </select>
        
    <insert id="insertTExamPaperQuestion" parameterType="TExamPaperQuestion">
        insert into t_exam_paper_question
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="paperId != null ">paper_id,</if>
            <if test="questionId != null ">question_id,</if>
            <if test="permanentId != null  and permanentId != ''">permanent_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="paperId != null ">#{paperId},</if>
            <if test="questionId != null ">#{questionId},</if>
            <if test="permanentId != null  and permanentId != ''">#{permanentId},</if>
         </trim>
    </insert>
 
    <update id="updateTExamPaperQuestion" parameterType="TExamPaperQuestion">
        update t_exam_paper_question
        <trim prefix="SET" suffixOverrides=",">
            <if test="questionId != null ">question_id = #{questionId},</if>
            <if test="permanentId != null  and permanentId != ''">permanent_id = #{permanentId},</if>
        </trim>
        where paper_id = #{paperId}
    </update>
 
    <delete id="deleteTExamPaperQuestionById" parameterType="Long">
        delete from t_exam_paper_question where paper_id = #{paperId}
    </delete>
 
    <delete id="deleteTExamPaperQuestionByIds" parameterType="String">
        delete from t_exam_paper_question where paper_id in 
        <foreach item="paperId" collection="array" open="(" separator="," close=")">
            #{paperId}
        </foreach>
    </delete>
    
</mapper>