BasicCourseMapper.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.qmth.teachcloud.common.mapper.BasicCourseMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.qmth.teachcloud.common.entity.BasicCourse">
  6. <result column="id" property="id"/>
  7. <result column="school_id" property="schoolId"/>
  8. <result column="code" property="code"/>
  9. <result column="name" property="name"/>
  10. <result column="create_id" property="createId"/>
  11. <result column="create_time" property="createTime"/>
  12. <result column="update_id" property="updateId"/>
  13. <result column="update_time" property="updateTime"/>
  14. </resultMap>
  15. <!-- 通用查询结果列 -->
  16. <sql id="Base_Column_List">
  17. select id,
  18. school_id,
  19. code,
  20. name,
  21. create_id,
  22. create_time,
  23. update_id,
  24. update_time
  25. from basic_course
  26. </sql>
  27. <select id="listCoursesByUserId" resultMap="BaseResultMap">
  28. SELECT a.id,
  29. a.code,
  30. a.name
  31. FROM basic_course a
  32. JOIN
  33. basic_user_course b ON a.id = b.course_id
  34. WHERE b.user_id = #{id}
  35. </select>
  36. <select id="listPage" resultMap="BaseResultMap">
  37. <include refid="Base_Column_List"></include>
  38. <where>
  39. <if test="schoolId != null and schoolId != ''">
  40. and school_id = #{schoolId}
  41. </if>
  42. <if test="code != null and code != ''">
  43. and code like concat('%',#{code} ,'%')
  44. </if>
  45. <if test="name != null and name != ''">
  46. and name like concat('%',#{name} ,'%')
  47. </if>
  48. </where>
  49. order by create_time desc
  50. </select>
  51. <select id="findByUserLoginNameAndRealName"
  52. resultType="com.qmth.teachcloud.common.bean.dto.CourseInfoDto">
  53. SELECT bc.code AS courseCode,
  54. bc.name AS courseName
  55. FROM basic_course bc
  56. INNER JOIN
  57. basic_user_course buc ON buc.course_id = bc.id
  58. INNER JOIN
  59. sys_user su ON su.id = buc.user_id
  60. WHERE su.login_name = #{loginName}
  61. AND real_name = #{realName};
  62. </select>
  63. <select id="findBasicCoursePage" resultType="com.qmth.teachcloud.common.bean.result.BasicCourseResult">
  64. SELECT
  65. bc.id,
  66. bc.code AS courseCode,
  67. bc.name AS courseName,
  68. teaching_room_id AS teachingRoomId,
  69. org.name AS teachingRoomName,
  70. bc.enable AS enable,
  71. bc.create_id AS createId,
  72. bc.create_time AS createTime
  73. FROM
  74. basic_course bc
  75. LEFT JOIN
  76. sys_org org ON bc.teaching_room_id = org.id
  77. AND org.enable = TRUE
  78. <where>
  79. <if test="belongOrgId != null and belongOrgId != ''">
  80. AND bc.teaching_room_id = #{belongOrgId}
  81. </if>
  82. <if test="courseName != null and courseName != ''">
  83. AND bc.name LIKE CONCAT('%',#{courseName},'%')
  84. </if>
  85. <if test="startCreateTime != null and startCreateTime != ''">
  86. AND bc.create_time >= #{startCreateTime}
  87. </if>
  88. <if test="endCreateTime != null and endCreateTime != ''">
  89. AND #{endCreateTime} >= bc.create_time
  90. </if>
  91. <if test="schoolId != null and schoolId != ''">
  92. and bc.school_id = #{schoolId}
  93. </if>
  94. <if test="orgIds != null and orgIds != '' and orgIds.size > 0">
  95. AND bc.teaching_room_id IN
  96. <foreach collection="orgIds" item="item" index="index" open="(" separator="," close=")">
  97. #{item}
  98. </foreach>
  99. </if>
  100. </where>
  101. ORDER BY createTime DESC
  102. </select>
  103. <select id="findExamTaskByCourseCode" resultType="java.util.Map">
  104. SELECT
  105. course_code AS courseCode, course_name AS courseName
  106. FROM
  107. exam_task
  108. <where>
  109. AND school_id = #{schoolId}
  110. <if test="courseCodeSet != null and courseCodeSet != '' and courseCodeSet.size > 0">
  111. AND course_code IN
  112. <foreach collection="courseCodeSet" item="item" index="index" open="(" separator="," close=")">
  113. #{item}
  114. </foreach>
  115. </if>
  116. </where>
  117. GROUP BY course_code,course_name
  118. </select>
  119. </mapper>