LearnTestStudentMapper.xml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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.LearnTestStudentMapper">
  6. <resultMap type="LearnTestStudent" id="LearnTestStudentResult">
  7. <id property="id" column="id" />
  8. <result property="batchId" column="batch_id" />
  9. <result property="studentId" column="student_id" />
  10. <result property="buildType" column="build_type" />
  11. <result property="subjectId" column="subject_id" />
  12. <result property="directKey" column="direct_key" />
  13. <result property="paperId" column="paper_id" />
  14. <result property="classId" column="class_id" />
  15. <result property="schoolId" column="school_id" />
  16. <result property="campusId" column="campus_id" />
  17. <result property="planId" column="plan_id" />
  18. <result property="creatorId" column="creator_id" />
  19. <result property="examineeId" column="examinee_id" />
  20. <result property="status" column="status" />
  21. <result property="createTime" column="create_time" />
  22. </resultMap>
  23. <sql id="selectLearnTestStudentVo">
  24. select id, batch_id, student_id, build_type, subject_id, direct_key, paper_id, class_id, school_id, campus_id, plan_id, creator_id, examinee_id, status, create_time from learn_test_student
  25. </sql>
  26. <select id="selectExamineeTestList" resultType="com.alibaba.fastjson2.JSONObject">
  27. SELECT ts.id, p.`paperName` `name`, ts.`subject_id` subjectId, e.`begin_time` beginTime, e.`duration`, p.`fenshu` total, e.`end_time` endTime, IF(e.`state` IS NULL, 2, e.`state`) `state`, e.`score`
  28. , ts.create_time publishTime, u.`nick_name` publishUser, p.`direct_key` directKey, us.`name` universityName, sr.`name` schoolName, sc.`name` campusName, mp.`majorName`, ts.`class_id` classId, ts.build_type buildType, dc.`name` className, t.`name` batchName
  29. FROM `learn_test_student` ts JOIN learn_student ls ON ts.`class_id` = ls.`class_id` AND ts.`student_id` = ls.`student_id`
  30. JOIN learn_test t on t.`batch_id` = ts.`batch_id` JOIN dz_classes dc on dc.`class_id` = ts.`class_id`
  31. JOIN `learn_paper` p ON ts.`paper_id` = p.`id`
  32. LEFT JOIN `learn_examinee` e ON ts.`examinee_id` = e.`examinee_id`
  33. LEFT JOIN sys_user u ON ts.`creator_id` = u.`user_id`
  34. LEFT JOIN `dz_school` sr ON ts.`school_id` = sr.`id`
  35. LEFT JOIN `dz_school` sc ON ts.`campus_id` = sc.`id`
  36. LEFT JOIN `a_marjor_plan` mp ON ts.`plan_id` = mp.`id`
  37. LEFT JOIN `b_busi_wish_universities` us ON SUBSTRING_INDEX(p.`direct_key`, '_', 1) = us.`id`
  38. <where>
  39. <if test="studentId != null "> and ts.`student_id` = #{studentId}</if>
  40. <if test="state != null and state != 4"> and IF(e.`state` IS NULL, 2, e.`state`) &lt; 4</if>
  41. <if test="state != null and state == 4"> and e.`state` &gt;= 4</if>
  42. </where>
  43. ORDER BY ts.`create_time` DESC
  44. </select>
  45. <select id="selectDirectedStudentList" parameterType="LearnTestStudent" resultMap="LearnTestStudentResult">
  46. <include refid="selectLearnTestStudentVo"/>
  47. <where>
  48. <if test="batchId != null "> and batch_id = #{batchId}</if>
  49. <if test="studentId != null "> and student_id = #{studentId}</if>
  50. <if test="buildType != null "> and build_type = #{buildType}</if>
  51. <if test="subjectId != null "> and subject_id = #{subjectId}</if>
  52. <if test="directKey != null and directKey != ''"> and direct_key = #{directKey}</if>
  53. <if test="paperId != null "> and paper_id = #{paperId}</if>
  54. <if test="classId != null "> and class_id = #{classId}</if>
  55. <if test="schoolId != null "> and school_id = #{schoolId}</if>
  56. <if test="campusId != null "> and campus_id = #{campusId}</if>
  57. <if test="planId != null "> and plan_id = #{planId}</if>
  58. <if test="creatorId != null "> and creator_id = #{creatorId}</if>
  59. <if test="examineeId != null "> and examinee_id = #{examineeId}</if>
  60. <if test="status != null "> and status = #{status}</if>
  61. </where>
  62. </select>
  63. <select id="selectStatsForStudent" parameterType="Long" resultMap="LearnTestStudentResult">
  64. SELECT ts.status, COUNT(*) count FROM learn_test_student ts JOIN learn_student ls ON ts.`class_id` = ls.`class_id` AND ts.`student_id` = ls.`student_id`
  65. WHERE ts.`student_id` = #{studentId}
  66. </select>
  67. <select id="selectLearnTestStudentList" parameterType="LearnTestStudent" resultMap="LearnTestStudentResult">
  68. <include refid="selectLearnTestStudentVo"/>
  69. <where>
  70. <if test="batchId != null "> and batch_id = #{batchId}</if>
  71. <if test="studentId != null "> and student_id = #{studentId}</if>
  72. <if test="buildType != null "> and build_type = #{buildType}</if>
  73. <if test="subjectId != null "> and subject_id = #{subjectId}</if>
  74. <if test="directKey != null and directKey != ''"> and direct_key = #{directKey}</if>
  75. <if test="paperId != null "> and paper_id = #{paperId}</if>
  76. <if test="classId != null "> and class_id = #{classId}</if>
  77. <if test="schoolId != null "> and school_id = #{schoolId}</if>
  78. <if test="campusId != null "> and campus_id = #{campusId}</if>
  79. <if test="planId != null "> and plan_id = #{planId}</if>
  80. <if test="creatorId != null "> and creator_id = #{creatorId}</if>
  81. <if test="examineeId != null "> and examinee_id = #{examineeId}</if>
  82. <if test="status != null "> and status = #{status}</if>
  83. </where>
  84. </select>
  85. <select id="selectLearnTestStudentById" parameterType="Long" resultMap="LearnTestStudentResult">
  86. <include refid="selectLearnTestStudentVo"/>
  87. where id = #{id}
  88. </select>
  89. <insert id="insertLearnTestStudent" parameterType="LearnTestStudent" useGeneratedKeys="true" keyProperty="id">
  90. insert into learn_test_student
  91. <trim prefix="(" suffix=")" suffixOverrides=",">
  92. <if test="batchId != null">batch_id,</if>
  93. <if test="studentId != null">student_id,</if>
  94. <if test="buildType != null">build_type,</if>
  95. <if test="subjectId != null">subject_id,</if>
  96. <if test="directKey != null and directKey != ''">direct_key,</if>
  97. <if test="paperId != null">paper_id,</if>
  98. <if test="classId != null">class_id,</if>
  99. <if test="schoolId != null">school_id,</if>
  100. <if test="campusId != null">campus_id,</if>
  101. <if test="planId != null">plan_id,</if>
  102. <if test="creatorId != null">creator_id,</if>
  103. <if test="examineeId != null">examinee_id,</if>
  104. <if test="status != null">status,</if>
  105. <if test="createTime != null">create_time,</if>
  106. </trim>
  107. <trim prefix="values (" suffix=")" suffixOverrides=",">
  108. <if test="batchId != null">#{batchId},</if>
  109. <if test="studentId != null">#{studentId},</if>
  110. <if test="buildType != null">#{buildType},</if>
  111. <if test="subjectId != null">#{subjectId},</if>
  112. <if test="directKey != null and directKey != ''">#{directKey},</if>
  113. <if test="paperId != null">#{paperId},</if>
  114. <if test="classId != null">#{classId},</if>
  115. <if test="schoolId != null">#{schoolId},</if>
  116. <if test="campusId != null">#{campusId},</if>
  117. <if test="planId != null">#{planId},</if>
  118. <if test="creatorId != null">#{creatorId},</if>
  119. <if test="examineeId != null">#{examineeId},</if>
  120. <if test="status != null">#{status},</if>
  121. <if test="createTime != null">#{createTime},</if>
  122. </trim>
  123. </insert>
  124. <update id="updateLearnTestStudent" parameterType="LearnTestStudent">
  125. update learn_test_student
  126. <trim prefix="SET" suffixOverrides=",">
  127. <if test="batchId != null">batch_id = #{batchId},</if>
  128. <if test="studentId != null">student_id = #{studentId},</if>
  129. <if test="buildType != null">build_type = #{buildType},</if>
  130. <if test="subjectId != null">subject_id = #{subjectId},</if>
  131. <if test="directKey != null and directKey != ''">direct_key = #{directKey},</if>
  132. <if test="paperId != null">paper_id = #{paperId},</if>
  133. <if test="classId != null">class_id = #{classId},</if>
  134. <if test="examineeId != null">examinee_id = #{examineeId},</if>
  135. <if test="status != null">status = #{status},</if>
  136. <if test="createTime != null">create_time = #{createTime},</if>
  137. </trim>
  138. where id = #{id}
  139. </update>
  140. <update id="updateExamineeStatus" parameterType="LearnTestStudent">
  141. update learn_test_student set status = #{status} where examinee_id = #{examineeId}
  142. </update>
  143. <delete id="deleteLearnTestStudentById" parameterType="Long">
  144. delete from learn_test_student where id = #{id}
  145. </delete>
  146. <delete id="deleteLearnTestStudentByIds" parameterType="Long">
  147. delete from learn_test_student where id in
  148. <foreach item="id" collection="array" open="(" separator="," close=")">
  149. #{id}
  150. </foreach>
  151. </delete>
  152. </mapper>