CourseSubjectMapper.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 = #{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. </mapper>