BaseClassCourse.xml 5.4 KB

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