CourseSubjectMapper.xml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. </resultMap>
  15. <resultMap type="com.zhongzheng.modules.course.vo.CourseProjectTypeVo" id="CourseProjectTypeVoResult">
  16. <result property="id" column="id"/>
  17. <result property="projectName" column="project_name"/>
  18. <result property="encoder" column="encoder"/>
  19. <result property="remark" column="remark"/>
  20. <result property="educationId" column="education_id"/>
  21. <result property="educationName" column="education_name"/>
  22. <result property="status" column="status"/>
  23. </resultMap>
  24. <resultMap type="com.zhongzheng.modules.course.vo.CourseSubjectVo" id="CourseSubjectVoResult">
  25. <result property="id" column="id"/>
  26. <result property="encoder" column="encoder"/>
  27. <result property="remark" column="remark"/>
  28. <result property="status" column="status"/>
  29. <result property="subjectName" column="subject_name"/>
  30. </resultMap>
  31. <resultMap type="com.zhongzheng.modules.course.vo.CourseProjectTypeVo" id="CourseProjectTypeVoTwoResult">
  32. <result property="id" column="pid"/>
  33. <result property="projectName" column="pproject_name"/>
  34. <result property="encoder" column="pencoder"/>
  35. <result property="remark" column="premark"/>
  36. <result property="educationId" column="peducation_id"/>
  37. <result property="educationName" column="peducation_name"/>
  38. <result property="status" column="pstatus"/>
  39. </resultMap>
  40. <select id="selectProject" parameterType="com.zhongzheng.modules.course.bo.CourseProjectTypeQueryBo" resultMap="CourseProjectTypeVoResult">
  41. SELECT
  42. p.*,
  43. e.education_name
  44. FROM
  45. course_subject_project j
  46. LEFT JOIN course_project_type p on p.id=j.project_id
  47. LEFT JOIN course_education_type e ON p.education_id = e.id
  48. where 1=1
  49. <if test="status != null and status.size()!=0 ">
  50. AND p.status in
  51. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  52. #{item}
  53. </foreach>
  54. </if>
  55. <if test="id != null and id!=0 ">
  56. AND j.subject_id = #{id}
  57. </if>
  58. </select>
  59. <select id="queryList" parameterType="com.zhongzheng.modules.course.bo.CourseSubjectQueryBo" resultMap="CourseSubjectVoResult">
  60. SELECT
  61. s.*
  62. FROM
  63. course_subject s
  64. WHERE
  65. 1 =1
  66. <if test="status != null and status.size()!=0 ">
  67. AND s.status in
  68. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  69. #{item}
  70. </foreach>
  71. </if>
  72. <if test="educationId != null and educationId!=0 ">
  73. 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
  74. </if>
  75. <if test="projectId != null and projectId!=0 ">
  76. and (SELECT COUNT(t.id) FROM course_subject_project t where t.project_id = #{projectId} AND t.subject_id = s.id) > 0
  77. </if>
  78. <if test="subjectName != null and subjectName!='' ">
  79. AND s.subject_name = #{subjectName}
  80. </if>
  81. <if test="wrong != null and wrong!=0 ">
  82. and (select COUNT(v.id) FROM course_subject_project v where s.id=v.subject_id) = 0
  83. </if>
  84. <if test="id != null and id!='' ">
  85. and s.id = #{id}
  86. </if>
  87. order by s.update_time desc
  88. </select>
  89. <select id="queryProject" parameterType="map" resultMap="CourseProjectTypeVoResult">
  90. SELECT
  91. p.*,
  92. (SELECT e.education_name FROM course_education_type e where p.education_id = e.id) as education_name,
  93. (SELECT e.id FROM course_education_type e where p.education_id = e.id) as education_id
  94. FROM
  95. course_project_type p
  96. LEFT JOIN course_subject_project j ON p.id = j.project_id
  97. WHERE
  98. j.subject_id=#{id}
  99. </select>
  100. </mapper>