CourseSubjectMapper.xml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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.zhongzheng.modules.course.mapper.CourseSubjectMapper">
  6. <resultMap type="com.zhongzheng.modules.course.domain.CourseSubject" id="CourseSubjectResult">
  7. <result property="id" column="id"/>
  8. <result property="encoder" column="encoder"/>
  9. <result property="remark" column="remark"/>
  10. <result property="status" column="status"/>
  11. <result property="createTime" column="create_time"/>
  12. <result property="updateTime" column="update_time"/>
  13. <result property="subjectName" column="subject_name"/>
  14. <result property="sort" column="sort"/>
  15. </resultMap>
  16. <resultMap type="com.zhongzheng.modules.course.vo.CourseProjectTypeVo" id="CourseProjectTypeVoResult">
  17. <result property="id" column="id"/>
  18. <result property="projectName" column="project_name"/>
  19. <result property="encoder" column="encoder"/>
  20. <result property="remark" column="remark"/>
  21. <result property="educationId" column="education_id"/>
  22. <result property="educationName" column="education_name"/>
  23. <result property="status" column="status"/>
  24. </resultMap>
  25. <resultMap type="com.zhongzheng.modules.course.vo.CourseSubjectVo" id="CourseSubjectVoResult">
  26. <result property="id" column="id"/>
  27. <result property="encoder" column="encoder"/>
  28. <result property="remark" column="remark"/>
  29. <result property="status" column="status"/>
  30. <result property="subjectName" column="subject_name"/>
  31. <result property="sort" column="sort"/>
  32. </resultMap>
  33. <resultMap type="com.zhongzheng.modules.course.vo.CourseProjectTypeVo" id="CourseProjectTypeVoTwoResult">
  34. <result property="id" column="pid"/>
  35. <result property="projectName" column="pproject_name"/>
  36. <result property="encoder" column="pencoder"/>
  37. <result property="remark" column="premark"/>
  38. <result property="educationId" column="peducation_id"/>
  39. <result property="educationName" column="peducation_name"/>
  40. <result property="status" column="pstatus"/>
  41. </resultMap>
  42. <select id="selectProject" parameterType="com.zhongzheng.modules.course.bo.CourseProjectTypeQueryBo" resultMap="CourseProjectTypeVoResult">
  43. SELECT
  44. p.*,
  45. e.education_name
  46. FROM
  47. course_subject_project j
  48. LEFT JOIN course_project_type p on p.id=j.project_id
  49. LEFT JOIN course_education_type e ON p.education_id = e.id
  50. where 1=1
  51. <if test="status != null and status.size()!=0 ">
  52. AND p.status in
  53. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  54. #{item}
  55. </foreach>
  56. </if>
  57. <if test="id != null and id!=0 ">
  58. AND j.subject_id = #{id}
  59. </if>
  60. </select>
  61. <select id="queryList" parameterType="com.zhongzheng.modules.course.bo.CourseSubjectQueryBo" resultMap="CourseSubjectVoResult">
  62. SELECT
  63. s.*
  64. FROM
  65. course_subject s
  66. WHERE
  67. 1 =1
  68. <if test="status != null and status.size()!=0 ">
  69. AND s.status in
  70. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  71. #{item}
  72. </foreach>
  73. </if>
  74. <if test="educationId != null and educationId!=0 ">
  75. and (SELECT COUNT(p.id) FROM course_subject_project t LEFT JOIN course_project_type p on t.project_id = p.id where p.education_id = #{educationId} AND t.subject_id = s.id ) > 0
  76. </if>
  77. <if test="projectId != null and projectId!=0 ">
  78. and (SELECT COUNT(t.id) FROM course_subject_project t where t.project_id = #{projectId} AND t.subject_id = s.id) > 0
  79. </if>
  80. <if test="businessId != null and businessId!=0 ">
  81. and (SELECT COUNT(t.id) FROM course_subject_project t LEFT JOIN course_business cb on cb.project_id = t.project_id where cb.id = #{businessId} AND t.subject_id = s.id) > 0
  82. </if>
  83. <if test="subjectName != null and subjectName!='' ">
  84. AND s.subject_name like concat('%', #{subjectName}, '%')
  85. </if>
  86. <if test="wrong != null and wrong!=0 ">
  87. and (select COUNT(v.id) FROM course_subject_project v where s.id=v.subject_id) = 0
  88. </if>
  89. <if test="id != null and id!='' ">
  90. and s.id = #{id}
  91. </if>
  92. order by s.sort
  93. </select>
  94. <select id="queryProject" parameterType="map" resultMap="CourseProjectTypeVoResult">
  95. SELECT
  96. p.*,
  97. (SELECT e.education_name FROM course_education_type e where p.education_id = e.id) as education_name,
  98. (SELECT e.id FROM course_education_type e where p.education_id = e.id) as education_id
  99. FROM
  100. course_project_type p
  101. LEFT JOIN course_subject_project j ON p.id = j.project_id
  102. WHERE
  103. j.subject_id=#{id}
  104. </select>
  105. <select id="countNum" parameterType="com.zhongzheng.modules.course.bo.CourseSubjectQueryBo" resultType="Integer">
  106. SELECT
  107. count(*)
  108. FROM
  109. course_subject cs
  110. LEFT JOIN course_subject_project csp ON cs.id = csp.subject_id
  111. WHERE
  112. cs.`status` != -1 and
  113. cs.subject_name = #{subjectName}
  114. <if test="courseSubjectProjects != null and courseSubjectProjects.length!=0 ">
  115. AND csp.project_id in
  116. <foreach collection="courseSubjectProjects" item="item" index="index" open="(" close=")" separator=",">
  117. #{item}
  118. </foreach>
  119. </if>
  120. <if test="id != null and id!='' ">
  121. and cs.id != #{id}
  122. </if>
  123. </select>
  124. <select id="getSubjectByTenant" parameterType="map" resultType="com.zhongzheng.modules.course.domain.CourseSubject">
  125. select * from course_subject where encoder = #{encoder} and tenant_id = #{newTenantId}
  126. </select>
  127. <select id="getIdsByTenant" parameterType="java.lang.String" resultType="java.lang.Long">
  128. select id from course_subject cs where cs.`status` = 1
  129. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cs.tenant_id AND sog.share_class = 1) > 0
  130. <if test="subNames != null and subNames.size()!=0 ">
  131. AND cs.subject_name in
  132. <foreach collection="subNames" item="item" index="index" open="(" close=")" separator=",">
  133. #{item}
  134. </foreach>
  135. </if>
  136. </select>
  137. <select id="listByIdsTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeListBo" resultType="com.zhongzheng.modules.course.domain.CourseSubject">
  138. select * from course_subject where `status` = 1
  139. <if test="subIds != null and subIds.size()!=0 ">
  140. AND id in
  141. <foreach collection="subIds" item="item" index="index" open="(" close=")" separator=",">
  142. #{item}
  143. </foreach>
  144. </if>
  145. </select>
  146. <select id="getListByIDs" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.course.domain.CourseSubject">
  147. select * from course_subject where `status` = 1
  148. <if test="ids != null and ids.size()!=0 ">
  149. AND id in
  150. <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
  151. #{item}
  152. </foreach>
  153. </if>
  154. </select>
  155. </mapper>