BaseClassCourse.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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.xjrsoft.module.base.mapper.BaseClassCourseMapper">
  6. <select id="getPage" parameterType="com.xjrsoft.module.base.dto.BaseClassCoursePageDto" resultType="com.xjrsoft.module.base.vo.BaseClassCoursePageVo">
  7. SELECT
  8. t.id AS class_id,
  9. t.name AS class_name,
  10. t1.name AS teacher_name,
  11. t3.name AS major_name,
  12. t4.name AS dept_name,
  13. (SELECT GROUP_CONCAT(DISTINCT t6.name SEPARATOR '、')
  14. FROM base_class_course t5
  15. LEFT JOIN base_course_subject t6 ON t6.id = t5.course_id
  16. WHERE t5.class_id = t.id
  17. AND t5.delete_mark = 0
  18. <if test="dto.semester != null">
  19. AND t5.base_semester_id = #{dto.semester}
  20. </if>
  21. ) AS course_name,
  22. (SELECT GROUP_CONCAT(DISTINCT t7.book_name SEPARATOR '、')
  23. FROM base_class_course t5
  24. LEFT JOIN textbook t7 ON t7.id = t5.textbook_id
  25. WHERE t5.class_id = t.id
  26. AND t5.delete_mark = 0
  27. <if test="dto.semester != null">
  28. AND t5.base_semester_id = #{dto.semester}
  29. </if>
  30. ) AS textbook_name
  31. FROM base_class t
  32. LEFT JOIN xjr_user t1 ON t1.id = t.teacher_id
  33. LEFT JOIN base_class_major_set t2 ON t2.class_id = t.id
  34. LEFT JOIN base_major_set t3 ON t3.id = t2.major_set_id
  35. LEFT JOIN xjr_department t4 ON t4.id = t.org_id
  36. WHERE t.delete_mark = 0
  37. <if test="dto.className != null and dto.className != ''">
  38. and t.name = #{dto.className}
  39. </if>
  40. <if test="dto.deptId != null">
  41. and t4.id = #{dto.deptId}
  42. </if>
  43. GROUP BY t.id, t.name, t1.name, t3.name, t4.name
  44. <if test="dto.courseSet == 1">
  45. HAVING LENGTH(course_name) > 0
  46. </if>
  47. <if test="dto.courseSet == 2">
  48. HAVING COALESCE(LENGTH(course_name), 0) = 0
  49. </if>
  50. </select>
  51. <select id="getAllCourseBook" resultType="com.xjrsoft.module.base.entity.CourseBookInfo">
  52. SELECT t.course_subject_id AS courseId,
  53. t1.name AS courseName,
  54. t.book_name AS bookName,
  55. t.id AS bookId,
  56. concat(t.course_subject_id, '_', t.id) AS id
  57. FROM textbook t
  58. LEFT JOIN base_course_subject t1 ON t.course_subject_id = t1.id
  59. WHERE t.delete_mark = 0
  60. AND t.course_subject_id IS NOT NULL
  61. <if test="subjectGroupId != null">
  62. AND t.subject_group_id = #{subjectGroupId}
  63. </if>
  64. <if test="semester != null">
  65. AND EXISTS (
  66. SELECT 1
  67. FROM textbook tb
  68. WHERE tb.id = t.id
  69. AND tb.base_semester_id = #{semester}
  70. )
  71. </if>
  72. </select>
  73. <select id="getSelectedCourseBook" resultType="com.xjrsoft.module.base.entity.CourseBookInfo">
  74. select t.course_id as courseId, t2.name as courseName, t1.book_name as bookName, t.textbook_id as bookId, concat(t.course_id, '_', t.textbook_id) AS id
  75. from base_class_course t
  76. left join textbook t1 on t1.id = t.textbook_id
  77. left join base_course_subject t2 on t.course_id = t2.id
  78. where t.delete_mark = 0
  79. <if test="classIds != null">
  80. AND t.class_id in
  81. <foreach item="classIds" collection="classIds" open="(" separator="," close=")">
  82. #{classIds}
  83. </foreach>
  84. </if>
  85. <if test="semester != null">
  86. and t.base_semester_id = #{semester}
  87. </if>
  88. <!-- <if test="subjectGroupId != null">-->
  89. <!-- AND-->
  90. <!-- </if>-->
  91. </select>
  92. <insert id="updateAddClassCourseTextbooks">
  93. INSERT INTO base_class_course (class_id, course_id, textbook_id, create_date, delete_mark, enabled_mark)
  94. VALUES (#{classId}, #{courseId}, #{textbookId},now(),0,1)
  95. ON DUPLICATE KEY UPDATE
  96. class_id = #{classId},
  97. course_id = #{courseId},
  98. textbook_id = #{textbookId}
  99. </insert>
  100. <update id="updateRemoveClassCourseTextbooks">
  101. UPDATE base_class_course
  102. SET delete_mark = 1
  103. WHERE class_id = #{classId}
  104. AND course_id = #{courseId}
  105. AND textbook_id = #{textbookId}
  106. </update>
  107. <update id="markExistingRecordsAsDeleted" parameterType="map">
  108. UPDATE base_class_course
  109. SET delete_mark = 1
  110. WHERE class_id = #{newClassId} AND (course_id IS NULL OR textbook_id IS NULL)
  111. </update>
  112. <insert id="insertClassCourseTextbookCombinations" parameterType="map">
  113. INSERT INTO base_class_course (class_id, course_id, textbook_id, create_date, delete_mark, enabled_mark)
  114. SELECT #{newClassId}, t.course_id, t.textbook_id, NOW(), 0, 1
  115. FROM (SELECT course_id, textbook_id FROM base_class_course WHERE class_id = #{sourceClassId} AND delete_mark = 0
  116. <if test="semester != null">
  117. AND EXISTS (
  118. SELECT 1
  119. FROM textbook tb
  120. WHERE tb.id = textbook_id
  121. AND tb.base_semester_id = #{semester}
  122. )
  123. </if>
  124. GROUP BY
  125. course_id, textbook_id
  126. ) t
  127. ON DUPLICATE KEY UPDATE
  128. delete_mark = 0,
  129. enabled_mark = 1,
  130. create_date = NOW()
  131. </insert>
  132. <select id="getClassIdByName" resultType="java.lang.Long">
  133. select t.id
  134. from base_class t
  135. where t.delete_mark = 0
  136. <if test="name != null">
  137. AND t.name = #{name}
  138. </if>
  139. </select>
  140. <select id="getCourseIdByName" resultType="java.lang.Long">
  141. select t.id
  142. from base_course_subject t
  143. where t.delete_mark = 0
  144. <if test="name != null">
  145. AND t.name = #{name}
  146. </if>
  147. </select>
  148. <select id="getBookIdByName" resultType="java.lang.Long">
  149. select t.id
  150. from textbook t
  151. where t.delete_mark = 0
  152. <if test="name != null">
  153. AND t.book_name = #{name}
  154. </if>
  155. </select>
  156. <select id="getBaseSemesterIdByName" resultType="java.lang.Long">
  157. select t.id
  158. from base_semester t
  159. where t.delete_mark = 0
  160. <if test="name != null">
  161. AND t.name = #{name}
  162. </if>
  163. </select>
  164. <select id="checkExits" resultType="java.lang.Boolean">
  165. SELECT COUNT(1)
  166. from base_class_course
  167. WHERE class_id = #{classId}
  168. AND course_id = #{courseId}
  169. AND textbook_id = #{textbookId}
  170. </select>
  171. </mapper>