LearnTestPaperMapper.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.learn.mapper.LearnTestPaperMapper">
  6. <resultMap type="LearnTestPaper" id="LearnTestPaperResult">
  7. <result property="id" column="id" />
  8. <result property="batchId" column="batch_id" />
  9. <result property="buildType" column="build_type" />
  10. <result property="subjectId" column="subject_id" />
  11. <result property="examType" column="exam_type" />
  12. <result property="teacherId" column="teacher_id" />
  13. <result property="universityId" column="university_id" />
  14. <result property="directKey" column="direct_key" />
  15. <result property="paperId" column="paper_id" />
  16. <result property="conditions" column="conditions" />
  17. <result property="creatorId" column="creator_id" />
  18. <result property="createTime" column="create_time" />
  19. </resultMap>
  20. <sql id="selectLearnTestPaperVo">
  21. select id, batch_id, build_type, subject_id, exam_type, teacher_id, university_id, direct_key, paper_id, conditions, creator_id, create_time from learn_test_paper
  22. </sql>
  23. <select id="selectLearnTestPaperList" parameterType="LearnTestPaper" resultMap="LearnTestPaperResult">
  24. <include refid="selectLearnTestPaperVo"/>
  25. <where>
  26. <if test="batchId != null "> and batch_id = #{batchId}</if>
  27. <if test="buildType != null "> and build_type = #{buildType}</if>
  28. <if test="subjectId != null "> and subject_id = #{subjectId}</if>
  29. <if test="examType != null "> and exam_type = #{examType}</if>
  30. <if test="teacherId != null "> and teacher_id = #{teacherId}</if>
  31. <if test="universityId != null "> and university_id = #{universityId}</if>
  32. <if test="directKey != null and directKey != ''"> and direct_key = #{directKey}</if>
  33. <if test="paperId != null "> and paper_id = #{paperId}</if>
  34. <if test="conditions != null and conditions != ''"> and conditions = #{conditions}</if>
  35. <if test="creatorId != null "> and creator_id = #{creatorId}</if>
  36. </where>
  37. </select>
  38. <select id="selectByBatchAndUniversityIds" resultMap="LearnTestPaperResult">
  39. <include refid="selectLearnTestPaperVo"/>
  40. <where> batch_id = #{batchId} and build_type = #{buildType} and subject_id = #{subjectId}
  41. <if test="null != teacherId">and teacher_id = #{teacherId}</if>
  42. <if test="null != universityIds">and university_id in <foreach item="id" collection="universityIds" open="(" separator="," close=")">#{id}</foreach></if>
  43. </where>
  44. </select>
  45. <select id="selectLearnTestPaperById" parameterType="String" resultMap="LearnTestPaperResult">
  46. <include refid="selectLearnTestPaperVo"/>
  47. where id = #{id}
  48. </select>
  49. <select id="selectLearnTestPaperByPaperId" parameterType="Long" resultMap="LearnTestPaperResult">
  50. <include refid="selectLearnTestPaperVo"/>
  51. where paper_id = #{paperId}
  52. </select>
  53. <insert id="insertLearnTestPaper" parameterType="LearnTestPaper" useGeneratedKeys="true" keyProperty="id">
  54. insert into learn_test_paper
  55. <trim prefix="(" suffix=")" suffixOverrides=",">
  56. <if test="batchId != null">batch_id,</if>
  57. <if test="buildType != null">build_type,</if>
  58. <if test="subjectId != null">subject_id,</if>
  59. <if test="examType != null">exam_type,</if>
  60. <if test="teacherId != null">teacher_id,</if>
  61. <if test="universityId != null">university_id,</if>
  62. <if test="directKey != null ">direct_key,</if>
  63. <if test="paperId != null">paper_id,</if>
  64. <if test="conditions != null">conditions,</if>
  65. <if test="creatorId != null">creator_id,</if>
  66. <if test="createTime != null">create_time,</if>
  67. </trim>
  68. <trim prefix="values (" suffix=")" suffixOverrides=",">
  69. <if test="batchId != null">#{batchId},</if>
  70. <if test="buildType != null">#{buildType},</if>
  71. <if test="subjectId != null">#{subjectId},</if>
  72. <if test="examType != null">#{examType},</if>
  73. <if test="teacherId != null">#{teacherId},</if>
  74. <if test="universityId != null">#{universityId},</if>
  75. <if test="directKey != null">#{directKey},</if>
  76. <if test="paperId != null">#{paperId},</if>
  77. <if test="conditions != null">#{conditions},</if>
  78. <if test="creatorId != null">#{creatorId},</if>
  79. <if test="createTime != null">#{createTime},</if>
  80. </trim>
  81. </insert>
  82. <update id="updateLearnTestPaper" parameterType="LearnTestPaper">
  83. update learn_test_paper
  84. <trim prefix="SET" suffixOverrides=",">
  85. <if test="batchId != null">batch_id = #{batchId},</if>
  86. <if test="buildType != null">build_type = #{buildType},</if>
  87. <if test="subjectId != null">subject_id = #{subjectId},</if>
  88. <if test="examType != null">exam_type = #{examType},</if>
  89. <if test="teacherId != null">teacher_id = #{teacherId},</if>
  90. <if test="universityId != null">university_id = #{universityId},</if>
  91. <if test="directKey != null">direct_key = #{directKey},</if>
  92. <if test="paperId != null">paper_id = #{paperId},</if>
  93. <if test="conditions != null">conditions = #{conditions},</if>
  94. <if test="creatorId != null">creator_id = #{creatorId},</if>
  95. <if test="createTime != null">create_time = #{createTime},</if>
  96. </trim>
  97. where id = #{id}
  98. </update>
  99. <delete id="deleteLearnTestPaperById" parameterType="String">
  100. delete from learn_test_paper where id = #{id}
  101. </delete>
  102. <delete id="deleteLearnTestPaperByIds" parameterType="String">
  103. delete from learn_test_paper where id in
  104. <foreach item="id" collection="array" open="(" separator="," close=")">
  105. #{id}
  106. </foreach>
  107. </delete>
  108. <select id="selectPapers" parameterType="java.util.Map" resultType="com.alibaba.fastjson2.JSONObject">
  109. SELECT
  110. t1.id,
  111. t1.batch_id batchId,
  112. t3.name batchName,
  113. t3.year batchYear,
  114. t1.build_type buildType,
  115. t1.subject_id subjectId,
  116. ds.subject_name subjectName,
  117. t1.exam_type examType,
  118. t1.teacher_id teacherId,
  119. t1.university_id universityId,
  120. t1.direct_key directKey,
  121. t1.paper_id paperId,
  122. t1.creator_id creatorId,
  123. t1.create_time createTime,
  124. t2.paperName,
  125. t2.year,
  126. t2.paperType,
  127. t2.number,
  128. t2.fenshu totalScore,
  129. t2.direct_key paperDirectKey,
  130. t2.paper_info paperInfo,
  131. t2.relate_id relateId
  132. FROM learn_test_paper t1
  133. JOIN learn_paper t2 ON t1.paper_id = t2.id
  134. JOIN dz_subject ds ON ds.subject_id = t1.subject_id
  135. JOIN learn_test t3 ON t1.batch_id = t3.batch_id
  136. WHERE 1=1
  137. <if test="creatorId != null and creatorId != ''">
  138. AND t1.creator_id = #{creatorId}
  139. </if>
  140. <if test="batchId != null and batchId != ''">
  141. AND t1.batch_id = #{batchId}
  142. </if>
  143. <if test="buildType != null and buildType != ''">
  144. AND t1.build_type = #{buildType}
  145. </if>
  146. <if test="examType != null and examType != ''">
  147. AND t1.exam_type = #{examType}
  148. </if>
  149. ORDER BY t1.create_time DESC
  150. </select>
  151. </mapper>