ExamRoomMapper.xml 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.keao.edu.user.dao.ExamRoomDao">
  8. <resultMap type="com.keao.edu.user.api.entity.ExamRoom" id="ExamRoom">
  9. <result column="id_" property="id" />
  10. <result column="examination_basic_id_" property="examinationBasicId"/>
  11. <result column="exam_mode_" property="examMode" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
  12. <result column="exam_location_id_" property="examLocationId" />
  13. <result column="subject_id_list_" property="subjectIdList" />
  14. <result column="main_teacher_user_id_" property="mainTeacherUserId" />
  15. <result column="assistant_teacher_user_id_list_" property="assistantTeacherUserIdList" />
  16. <result column="exam_start_time_" property="examStartTime" />
  17. <result column="exam_end_time_" property="examEndTime" />
  18. <result column="del_flag_" property="delFlag" />
  19. <result column="organ_id_" property="organId"/>
  20. <result column="exam_plan_push_flag_" property="examPlanPushFlag" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
  21. <result column="exam_room_student_num_" property="examRoomStudentNum"/>
  22. <result column="create_time_" property="createTime" />
  23. <result column="update_time_" property="updateTime" />
  24. <result column="tenant_id_" property="tenantId" />
  25. </resultMap>
  26. <!-- 根据主键查询一条记录 -->
  27. <select id="get" resultMap="ExamRoom" >
  28. SELECT * FROM exam_room WHERE id_ = #{id}
  29. </select>
  30. <!-- 全查询 -->
  31. <select id="findAll" resultMap="ExamRoom">
  32. SELECT * FROM exam_room ORDER BY id_
  33. </select>
  34. <!-- 向数据库增加一条记录 -->
  35. <insert id="insert" parameterType="com.keao.edu.user.api.entity.ExamRoom" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  36. INSERT INTO exam_room (id_,examination_basic_id_,exam_mode_,exam_location_id_,subject_id_list_,main_teacher_user_id_,
  37. assistant_teacher_user_id_list_,exam_start_time_,exam_end_time_,del_flag_,organ_id_,exam_plan_push_flag_,
  38. exam_room_student_num_,create_time_,update_time_,tenant_id_)
  39. VALUES(#{id},#{examinationBasicId},#{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{examLocationId},#{subjectIdList},
  40. #{mainTeacherUserId},#{assistantTeacherUserIdList},
  41. #{examStartTime},#{examEndTime},#{delFlag},#{organId},#{examPlanPushFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  42. #{examRoomStudentNum},NOW(),NOW(),#{tenantId})
  43. </insert>
  44. <insert id="batchInsert" parameterType="com.keao.edu.user.api.entity.ExamRoom" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  45. INSERT INTO exam_room (examination_basic_id_,exam_mode_,exam_location_id_,subject_id_list_,main_teacher_user_id_,
  46. assistant_teacher_user_id_list_,exam_start_time_,exam_end_time_,del_flag_,organ_id_,exam_plan_push_flag_,
  47. exam_room_student_num_,create_time_,update_time_,tenant_id_)
  48. VALUES
  49. <foreach collection="examRooms" item="examRoom" separator=",">
  50. (#{examRoom.examinationBasicId},#{examRoom.examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{examRoom.examLocationId},
  51. #{examRoom.subjectIdList},#{examRoom.mainTeacherUserId},#{examRoom.assistantTeacherUserIdList},
  52. #{examRoom.examStartTime},#{examRoom.examEndTime},#{examRoom.delFlag},#{examRoom.organId},#{examRoom.examPlanPushFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  53. #{examRoom.examRoomStudentNum},NOW(),NOW(),#{examRoom.tenantId})
  54. </foreach>
  55. </insert>
  56. <!-- 根据主键查询一条记录 -->
  57. <update id="update" parameterType="com.keao.edu.user.api.entity.ExamRoom">
  58. UPDATE exam_room
  59. <set>
  60. <if test="delFlag != null">
  61. del_flag_ = #{delFlag},
  62. </if>
  63. <if test="examinationBasicId != null">
  64. examination_basic_id_ = #{examinationBasicId},
  65. </if>
  66. <if test="examStartTime != null">
  67. exam_start_time_ = #{examStartTime},
  68. </if>
  69. <if test="examEndTime != null">
  70. exam_end_time_ = #{examEndTime},
  71. </if>
  72. <if test="subjectIdList != null">
  73. subject_id_list_ = #{subjectIdList},
  74. </if>
  75. <if test="tenantId != null">
  76. tenant_id_ = #{tenantId},
  77. </if>
  78. <if test="examMode != null">
  79. exam_mode_ = #{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  80. </if>
  81. <if test="examLocationId != null">
  82. exam_location_id_ = #{examLocationId},
  83. </if>
  84. <if test="mainTeacherUserId != null">
  85. main_teacher_user_id_ = #{mainTeacherUserId},
  86. </if>
  87. <if test="assistantTeacherUserIdList != null">
  88. assistant_teacher_user_id_list_ = #{assistantTeacherUserIdList},
  89. </if>
  90. <if test="organId != null">
  91. organ_id_ = #{organId},
  92. </if>
  93. <if test="examPlanPushFlag != null">
  94. exam_plan_push_flag_ = #{examPlanPushFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  95. </if>
  96. <if test="examRoomStudentNum!=null">
  97. exam_room_student_num_=#{examRoomStudentNum},
  98. </if>
  99. update_time_ = NOW()
  100. </set> WHERE id_ = #{id}
  101. </update>
  102. <update id="updateSL" parameterType="com.keao.edu.user.api.entity.ExamRoom">
  103. UPDATE exam_room
  104. <set>
  105. <if test="delFlag != null">
  106. del_flag_ = #{delFlag},
  107. </if>
  108. <if test="examinationBasicId != null">
  109. examination_basic_id_ = #{examinationBasicId},
  110. </if>
  111. <if test="examStartTime != null">
  112. exam_start_time_ = #{examStartTime},
  113. </if>
  114. <if test="examEndTime != null">
  115. exam_end_time_ = #{examEndTime},
  116. </if>
  117. <if test="subjectIdList != null">
  118. subject_id_list_ = #{subjectIdList},
  119. </if>
  120. <if test="tenantId != null">
  121. tenant_id_ = #{tenantId},
  122. </if>
  123. <if test="examMode != null">
  124. exam_mode_ = #{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  125. </if>
  126. <if test="examLocationId != null">
  127. exam_location_id_ = #{examLocationId},
  128. </if>
  129. <if test="mainTeacherUserId != null">
  130. main_teacher_user_id_ = #{mainTeacherUserId},
  131. </if>
  132. <if test="assistantTeacherUserIdList != null">
  133. assistant_teacher_user_id_list_ = #{assistantTeacherUserIdList},
  134. </if>
  135. <if test="organId != null">
  136. organ_id_ = #{organId},
  137. </if>
  138. <if test="examPlanPushFlag != null">
  139. exam_plan_push_flag_ = #{examPlanPushFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  140. </if>
  141. <if test="examRoomStudentNum!=null">
  142. exam_room_student_num_=#{examRoomStudentNum},
  143. </if>
  144. update_time_ = NOW()
  145. </set> WHERE id_ = #{id} AND update_time_=#{updateTime}
  146. </update>
  147. <!-- 根据主键删除一条记录 -->
  148. <delete id="delete" >
  149. DELETE FROM exam_room WHERE id_ = #{id}
  150. </delete>
  151. <delete id="batchDeleteExamRooms">
  152. DELETE FROM exam_room WHERE exam_plan_push_flag_=0 AND id_ IN
  153. <foreach collection="examRoomIds" item="examRoomId" separator="," open="(" close=")">
  154. #{examRoomId}
  155. </foreach>
  156. </delete>
  157. <!-- 分页查询 -->
  158. <select id="queryPage" resultMap="ExamRoom" parameterType="map">
  159. SELECT * FROM exam_room ORDER BY id_ <include refid="global.limit"/>
  160. </select>
  161. <!-- 查询当前表的总记录数 -->
  162. <select id="queryCount" resultType="int">
  163. SELECT COUNT(*) FROM exam_room
  164. </select>
  165. <sql id="queryExamRoomPageSql">
  166. <where>
  167. <if test="organIds!=null">
  168. AND er.organ_id_ IN
  169. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  170. #{organId}
  171. </foreach>
  172. </if>
  173. <if test="examRoomId!=null">
  174. AND er.id_=#{examRoomId}
  175. </if>
  176. <if test="examId!=null">
  177. AND er.examination_basic_id_ = #{examId}
  178. </if>
  179. <if test="tenantId != null">
  180. AND er.tenant_id_ = #{tenantId}
  181. </if>
  182. <if test="startTime != null">
  183. AND eb.expect_exam_start_time_ >= #{startTime}
  184. </if>
  185. <if test="endTime != null">
  186. AND eb.expect_exam_end_time_ &lt;= #{endTime}
  187. </if>
  188. <if test="search != null and search != ''">
  189. AND eb.name_ LIKE CONCAT('%',#{search},'%')
  190. </if>
  191. <if test="examStatusEnum != null and examStatusEnum != ''">
  192. AND eb.status_ = #{examStatusEnum}
  193. </if>
  194. </where>
  195. </sql>
  196. <resultMap type="com.keao.edu.user.dto.ExamRoomDto" id="ExamRoomDto" extends="ExamRoom">
  197. <association property="examLocation" javaType="com.keao.edu.user.entity.ExamLocation" resultMap="com.keao.edu.user.dao.ExamLocationDao.ExamLocation"/>
  198. <association property="examinationBasic" javaType="com.keao.edu.user.entity.ExaminationBasic" resultMap="com.keao.edu.user.dao.ExaminationBasicDao.ExaminationBasic"/>
  199. </resultMap>
  200. <select id="countExamRoomPage" resultType="java.lang.Integer">
  201. SELECT COUNT(er.id_) FROM exam_room er
  202. LEFT JOIN exam_location el ON er.exam_location_id_ = el.id_ AND er.tenant_id_ = el.tenant_id_
  203. LEFT JOIN examination_basic eb ON FIND_IN_SET(er.exam_location_id_,eb.exam_location_id_list_) AND er.tenant_id_ = eb.tenant_id_
  204. <include refid="queryExamRoomPageSql"/>
  205. </select>
  206. <select id="queryExamRoomPage" resultMap="ExamRoomDto">
  207. SELECT er.*,eb.* FROM exam_room er
  208. LEFT JOIN exam_location el ON er.exam_location_id_ = el.id_ AND er.tenant_id_ = el.tenant_id_
  209. LEFT JOIN examination_basic eb ON FIND_IN_SET(er.exam_location_id_,eb.exam_location_id_list_) AND er.tenant_id_ = eb.tenant_id_
  210. <include refid="queryExamRoomPageSql"/>
  211. ORDER BY eb.expect_exam_start_time_ DESC
  212. <include refid="global.limit"/>
  213. </select>
  214. <select id="getWithExam" resultMap="ExamRoom">
  215. SELECT * FROM exam_room WHERE examination_basic_id_=#{examId}
  216. <if test="organIds!=null">
  217. AND organ_id_ IN
  218. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  219. #{organId}
  220. </foreach>
  221. </if>
  222. </select>
  223. <select id="lockRoom" resultType="com.keao.edu.user.api.entity.ExamRoom">
  224. SELECT * FROM exam_room WHERE id_=#{examRoomId} FOR UPDATE
  225. </select>
  226. <select id="getWithDays" resultType="com.keao.edu.user.api.entity.ExamRoom">
  227. SELECT
  228. *
  229. FROM
  230. exam_room
  231. WHERE
  232. DATE_FORMAT( exam_start_time_, '%Y-%m-%d' ) IN
  233. <!--<foreach collection="" -->
  234. <!--OR DATE_FORMAT( exam_end_time_, '%Y-%m-%d' ) IN ( )-->
  235. </select>
  236. </mapper>