ExamRoomMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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="subject_name_list_" property="subjectNameList"/>
  15. <result column="main_teacher_user_id_" property="mainTeacherUserId" />
  16. <result column="main_teacher_user_name_" property="mainTeacherName"/>
  17. <result column="assistant_teacher_user_id_list_" property="assistantTeacherUserIdList" />
  18. <result column="assistant_teacher_user_name_list_" property="assistantTeacherUserNameList"/>
  19. <result column="exam_start_time_" property="examStartTime" />
  20. <result column="exam_end_time_" property="examEndTime" />
  21. <result column="del_flag_" property="delFlag" />
  22. <result column="organ_id_" property="organId"/>
  23. <result column="open_flag_" property="openFlag"/>
  24. <result column="exam_plan_push_flag_" property="examPlanPushFlag"/>
  25. <result column="exam_room_student_num_" property="examRoomStudentNum"/>
  26. <result column="create_time_" property="createTime" />
  27. <result column="update_time_" property="updateTime" />
  28. <result column="tenant_id_" property="tenantId" />
  29. <result column="exam_flag_" property="examFlag" />
  30. <result column="shield_user_id_" property="shieldUserId" />
  31. </resultMap>
  32. <!-- 根据主键查询一条记录 -->
  33. <select id="get" resultMap="ExamRoom" >
  34. SELECT * FROM exam_room WHERE id_ = #{id}
  35. </select>
  36. <!-- 全查询 -->
  37. <select id="findAll" resultMap="ExamRoom">
  38. SELECT * FROM exam_room ORDER BY id_
  39. </select>
  40. <!-- 向数据库增加一条记录 -->
  41. <insert id="insert" parameterType="com.keao.edu.user.api.entity.ExamRoom" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  42. INSERT INTO exam_room (id_,examination_basic_id_,exam_mode_,exam_location_id_,subject_id_list_,subject_name_list_,
  43. main_teacher_user_id_,main_teacher_user_name_,assistant_teacher_user_id_list_,assistant_teacher_user_name_list_,
  44. exam_start_time_,exam_end_time_,del_flag_,organ_id_,exam_plan_push_flag_,
  45. exam_room_student_num_,create_time_,update_time_,tenant_id_,exam_flag_)
  46. VALUES(#{id},#{examinationBasicId},#{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{examLocationId},
  47. #{subjectIdList},#{subjectNameList},#{mainTeacherUserId},#{mainTeacherName},#{assistantTeacherUserIdList},#{assistantTeacherUserNameList},
  48. #{examStartTime},#{examEndTime},#{delFlag},#{organId},#{examPlanPushFlag},
  49. #{examRoomStudentNum},NOW(),NOW(),#{tenantId},#{examFlag})
  50. </insert>
  51. <insert id="batchInsert" parameterType="com.keao.edu.user.api.entity.ExamRoom" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  52. INSERT INTO exam_room (examination_basic_id_,exam_mode_,exam_location_id_,subject_id_list_,subject_name_list_,
  53. main_teacher_user_id_,main_teacher_user_name_,assistant_teacher_user_id_list_,assistant_teacher_user_name_list_,
  54. exam_start_time_,exam_end_time_,del_flag_,organ_id_,exam_plan_push_flag_,
  55. exam_room_student_num_,create_time_,update_time_,tenant_id_)
  56. VALUES
  57. <foreach collection="examRooms" item="examRoom" separator=",">
  58. (#{examRoom.examinationBasicId},#{examRoom.examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{examRoom.examLocationId},
  59. #{examRoom.subjectIdList},#{examRoom.subjectNameList},
  60. #{examRoom.mainTeacherUserId},#{examRoom.mainTeacherName},#{examRoom.assistantTeacherUserIdList},#{examRoom.assistantTeacherUserNameList},
  61. #{examRoom.examStartTime},#{examRoom.examEndTime},#{examRoom.delFlag},#{examRoom.organId},#{examRoom.examPlanPushFlag},
  62. #{examRoom.examRoomStudentNum},NOW(),NOW(),#{examRoom.tenantId})
  63. </foreach>
  64. </insert>
  65. <!-- 根据主键查询一条记录 -->
  66. <update id="update" parameterType="com.keao.edu.user.api.entity.ExamRoom">
  67. UPDATE exam_room
  68. <set>
  69. <if test="shieldUserId != null">
  70. shield_user_id_ = #{shieldUserId},
  71. </if>
  72. <if test="examFlag != null">
  73. exam_flag_ = #{examFlag},
  74. </if>
  75. <if test="delFlag != null">
  76. del_flag_ = #{delFlag},
  77. </if>
  78. <if test="openFlag != null">
  79. open_flag_ = #{openFlag},
  80. </if>
  81. <if test="examinationBasicId != null">
  82. examination_basic_id_ = #{examinationBasicId},
  83. </if>
  84. <if test="examStartTime != null">
  85. exam_start_time_ = #{examStartTime},
  86. </if>
  87. <if test="examEndTime != null">
  88. exam_end_time_ = #{examEndTime},
  89. </if>
  90. <if test="subjectIdList != null">
  91. subject_id_list_ = #{subjectIdList},
  92. </if>
  93. <if test="subjectNameList != null">
  94. subject_name_list_ = #{subjectNameList},
  95. </if>
  96. <if test="tenantId != null and tenantId != 0">
  97. tenant_id_ = #{tenantId},
  98. </if>
  99. <if test="examMode != null">
  100. exam_mode_ = #{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  101. </if>
  102. exam_location_id_ = #{examLocationId},
  103. <if test="mainTeacherUserId != null">
  104. main_teacher_user_id_ = #{mainTeacherUserId},
  105. </if>
  106. <if test="mainTeacherName != null">
  107. main_teacher_user_name_ = #{mainTeacherName},
  108. </if>
  109. <if test="assistantTeacherUserIdList != null">
  110. assistant_teacher_user_id_list_ = #{assistantTeacherUserIdList},
  111. </if>
  112. <if test="assistantTeacherUserNameList != null">
  113. assistant_teacher_user_name_list_ = #{assistantTeacherUserNameList},
  114. </if>
  115. <if test="organId != null">
  116. organ_id_ = #{organId},
  117. </if>
  118. <if test="examPlanPushFlag != null">
  119. exam_plan_push_flag_ = #{examPlanPushFlag},
  120. </if>
  121. <if test="examRoomStudentNum!=null">
  122. exam_room_student_num_=#{examRoomStudentNum},
  123. </if>
  124. update_time_ = NOW()
  125. </set> WHERE id_ = #{id}
  126. </update>
  127. <!-- 根据主键查询一条记录 -->
  128. <update id="batchUpdate" parameterType="com.keao.edu.user.api.entity.ExamRoom">
  129. <foreach collection="examRooms" item="er" separator=";">
  130. UPDATE exam_room
  131. <set>
  132. <if test="er.delFlag != null">
  133. del_flag_ = #{er.delFlag},
  134. </if>
  135. <if test="er.openFlag != null">
  136. open_flag_ = #{er.openFlag},
  137. </if>
  138. <if test="er.examinationBasicId != null">
  139. examination_basic_id_ = #{er.examinationBasicId},
  140. </if>
  141. <if test="er.examStartTime != null">
  142. exam_start_time_ = #{er.examStartTime},
  143. </if>
  144. <if test="er.examEndTime != null">
  145. exam_end_time_ = #{er.examEndTime},
  146. </if>
  147. <if test="er.subjectIdList != null">
  148. subject_id_list_ = #{er.subjectIdList},
  149. </if>
  150. <if test="er.subjectNameList != null">
  151. subject_name_list_ = #{er.subjectNameList},
  152. </if>
  153. <if test="er.tenantId != null and er.tenantId != 0">
  154. tenant_id_ = #{er.tenantId},
  155. </if>
  156. <if test="er.examMode != null">
  157. exam_mode_ = #{er.examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  158. </if>
  159. exam_location_id_ = #{er.examLocationId},
  160. <if test="er.mainTeacherUserId != null">
  161. main_teacher_user_id_ = #{er.mainTeacherUserId},
  162. </if>
  163. <if test="er.mainTeacherName != null">
  164. main_teacher_user_name_ = #{er.mainTeacherName},
  165. </if>
  166. <if test="er.assistantTeacherUserIdList != null">
  167. assistant_teacher_user_id_list_ = #{er.assistantTeacherUserIdList},
  168. </if>
  169. <if test="er.assistantTeacherUserNameList != null">
  170. assistant_teacher_user_name_list_ = #{er.assistantTeacherUserNameList},
  171. </if>
  172. <if test="er.organId != null">
  173. organ_id_ = #{er.organId},
  174. </if>
  175. <if test="er.examPlanPushFlag != null">
  176. exam_plan_push_flag_ = #{er.examPlanPushFlag},
  177. </if>
  178. <if test="er.examRoomStudentNum!=null">
  179. exam_room_student_num_=#{er.examRoomStudentNum},
  180. </if>
  181. update_time_ = NOW()
  182. </set> WHERE id_ = #{er.id}
  183. </foreach>
  184. </update>
  185. <update id="updateSL" parameterType="com.keao.edu.user.api.entity.ExamRoom">
  186. UPDATE exam_room
  187. <set>
  188. <if test="delFlag != null">
  189. del_flag_ = #{delFlag},
  190. </if>
  191. <if test="examinationBasicId != null">
  192. examination_basic_id_ = #{examinationBasicId},
  193. </if>
  194. <if test="examStartTime != null">
  195. exam_start_time_ = #{examStartTime},
  196. </if>
  197. <if test="examEndTime != null">
  198. exam_end_time_ = #{examEndTime},
  199. </if>
  200. <if test="subjectIdList != null">
  201. subject_id_list_ = #{subjectIdList},
  202. </if>
  203. <if test="subjectNameList != null">
  204. subject_name_list_ = #{subjectNameList},
  205. </if>
  206. <if test="tenantId != null and tenantId != 0">
  207. tenant_id_ = #{tenantId},
  208. </if>
  209. <if test="examMode != null">
  210. exam_mode_ = #{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  211. </if>
  212. exam_location_id_ = #{examLocationId},
  213. <if test="mainTeacherUserId != null">
  214. main_teacher_user_id_ = #{mainTeacherUserId},
  215. </if>
  216. <if test="mainTeacherName != null">
  217. main_teacher_user_name_ = #{mainTeacherName},
  218. </if>
  219. <if test="assistantTeacherUserIdList != null">
  220. assistant_teacher_user_id_list_ = #{assistantTeacherUserIdList},
  221. </if>
  222. <if test="assistantTeacherUserNameList != null">
  223. assistant_teacher_user_name_list_ = #{assistantTeacherUserNameList},
  224. </if>
  225. <if test="organId != null">
  226. organ_id_ = #{organId},
  227. </if>
  228. <if test="examPlanPushFlag != null">
  229. exam_plan_push_flag_ = #{examPlanPushFlag},
  230. </if>
  231. <if test="examRoomStudentNum!=null">
  232. exam_room_student_num_=#{examRoomStudentNum},
  233. </if>
  234. update_time_ = NOW()
  235. </set> WHERE id_ = #{id} AND update_time_=#{updateTime}
  236. </update>
  237. <!-- 根据主键删除一条记录 -->
  238. <delete id="delete" >
  239. DELETE FROM exam_room WHERE id_ = #{id}
  240. </delete>
  241. <delete id="batchDeleteExamRooms">
  242. DELETE FROM exam_room WHERE exam_plan_push_flag_=0 AND id_ IN
  243. <foreach collection="examRoomIds" item="examRoomId" separator="," open="(" close=")">
  244. #{examRoomId}
  245. </foreach>
  246. </delete>
  247. <!-- 分页查询 -->
  248. <select id="queryPage" resultMap="ExamRoom" parameterType="map">
  249. SELECT * FROM exam_room ORDER BY id_ <include refid="global.limit"/>
  250. </select>
  251. <!-- 查询当前表的总记录数 -->
  252. <select id="queryCount" resultType="int">
  253. SELECT COUNT(*) FROM exam_room
  254. </select>
  255. <sql id="queryExamRoomPageSql">
  256. <where>
  257. <if test="organIds!=null">
  258. AND er.organ_id_ IN
  259. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  260. #{organId}
  261. </foreach>
  262. </if>
  263. <if test="examRoomId!=null">
  264. AND er.id_ = #{examRoomId}
  265. </if>
  266. <if test="examId!=null">
  267. AND er.examination_basic_id_ = #{examId}
  268. </if>
  269. <if test="tenantId != null and tenantId != 0">
  270. AND er.tenant_id_ = #{tenantId}
  271. </if>
  272. <if test="startTime != null">
  273. AND eb.expect_exam_start_time_ >= #{startTime}
  274. </if>
  275. <if test="endTime != null">
  276. AND eb.expect_exam_end_time_ &lt;= #{endTime}
  277. </if>
  278. <if test="search != null and search != ''">
  279. AND eb.name_ LIKE CONCAT('%',#{search},'%')
  280. </if>
  281. <if test="examStatusEnum != null and examStatusEnum != ''">
  282. AND eb.status_ = #{examStatusEnum}
  283. </if>
  284. </where>
  285. </sql>
  286. <resultMap type="com.keao.edu.user.dto.ExamRoomDto" id="ExamRoomDto" extends="ExamRoom">
  287. <association property="examLocation" columnPrefix="el_" resultMap="com.keao.edu.user.dao.ExamLocationDao.ExamLocation"/>
  288. <association property="examinationBasic" columnPrefix="exam_" resultMap="com.keao.edu.user.dao.ExaminationBasicDao.ExaminationBasic"/>
  289. </resultMap>
  290. <resultMap id="ExamRoomListDtoMap" type="com.keao.edu.user.dto.ExamRoomListDto">
  291. <result property="examEndTime" column="exam_end_time_"/>
  292. <result property="examStartTime" column="exam_start_time_"/>
  293. <result property="openFlag" column="open_flag_"/>
  294. <result property="examRoomId" column="exam_room_id_"/>
  295. <result property="assistantTeacherUserIdList" column="assistant_teacher_user_id_list_"/>
  296. <result property="assistantTeacherUserNameList" column="assistant_teacher_user_name_list_"/>
  297. <result property="examBaseStatus" column="exam_base_status_"/>
  298. <result property="examName" column="exam_name_"/>
  299. <result property="getMainTeacherUserId" column="main_teacher_user_id_"/>
  300. <result property="mainTeacherUserName" column="main_teacher_user_name_"/>
  301. <result property="subjectNameList" column="subject_name_list_"/>
  302. </resultMap>
  303. <sql id="queryExamRoomPageListSql">
  304. <where>
  305. (er.main_teacher_user_id_ = #{teacherId} OR FIND_IN_SET(#{teacherId},er.assistant_teacher_user_id_list_))
  306. <if test="startTime != null and startTime != ''">
  307. AND DATE_FORMAT(er.exam_end_time_,'%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
  308. </if>
  309. <if test="examBaseStatus != null and examBaseStatus != ''">
  310. AND eb.status_ = #{examBaseStatus}
  311. </if>
  312. <if test="examMode != null and examMode != ''">
  313. AND er.exam_mode_ = #{examMode}
  314. </if>
  315. <if test="openFlag != null and openFlag == 1">
  316. AND er.open_flag_ = #{openFlag}
  317. </if>
  318. <if test="openFlag != null and openFlag == 0">
  319. AND er.open_flag_ = #{openFlag}
  320. </if>
  321. </where>
  322. </sql>
  323. <select id="countExamRoomPage" resultType="java.lang.Integer">
  324. SELECT COUNT(er.id_)
  325. FROM exam_room er
  326. LEFT JOIN examination_basic eb ON er.examination_basic_id_ = eb.id_
  327. <include refid="queryExamRoomPageListSql"/>
  328. </select>
  329. <select id="queryExamRoomPage" resultMap="ExamRoomListDtoMap">
  330. SELECT eb.name_ exam_name_,er.exam_end_time_,er.exam_start_time_,
  331. er.id_ exam_room_id_,er.subject_name_list_,er.main_teacher_user_name_,er.main_teacher_user_id_,
  332. er.assistant_teacher_user_id_list_,er.assistant_teacher_user_name_list_,eb.status_ exam_base_status_,er.open_flag_
  333. FROM exam_room er
  334. LEFT JOIN examination_basic eb ON er.examination_basic_id_ = eb.id_
  335. <include refid="queryExamRoomPageListSql"/>
  336. ORDER BY er.exam_start_time_ DESC
  337. <include refid="global.limit"/>
  338. </select>
  339. <sql id="queryExamRoomCondition">
  340. <where>
  341. <if test="organIds!=null">
  342. AND er.organ_id_ IN
  343. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  344. #{organId}
  345. </foreach>
  346. </if>
  347. <if test="examRoomId!=null">
  348. AND er.id_=#{examRoomId}
  349. </if>
  350. <if test="examId!=null">
  351. AND er.examination_basic_id_ = #{examId}
  352. </if>
  353. <if test="search!=null and search!=''">
  354. AND (er.id_=#{search})
  355. </if>
  356. </where>
  357. </sql>
  358. <select id="queryExamRoom" resultMap="ExamRoomDto">
  359. SELECT
  360. er.*,
  361. el.id_ el_id_,
  362. el.name_ el_name_
  363. FROM exam_room er
  364. LEFT JOIN exam_location el ON er.exam_location_id_ = el.id_
  365. <include refid="queryExamRoomCondition"/>
  366. ORDER BY er.id_ DESC
  367. <include refid="global.limit"/>
  368. </select>
  369. <select id="countExamRoom" resultType="java.lang.Integer">
  370. SELECT COUNT(er.id_) FROM exam_room er
  371. LEFT JOIN exam_location el ON er.exam_location_id_ = el.id_
  372. <include refid="queryExamRoomCondition"/>
  373. </select>
  374. <select id="getWithExam" resultMap="ExamRoom">
  375. SELECT * FROM exam_room WHERE examination_basic_id_=#{examId}
  376. <if test="organIds!=null">
  377. AND organ_id_ IN
  378. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  379. #{organId}
  380. </foreach>
  381. </if>
  382. </select>
  383. <select id="lockRoom" resultMap="ExamRoom">
  384. SELECT * FROM exam_room WHERE id_=#{examRoomId} FOR UPDATE
  385. </select>
  386. <select id="getWithDays" resultMap="ExamRoom">
  387. SELECT
  388. *
  389. FROM
  390. exam_room
  391. WHERE
  392. DATE_FORMAT( exam_start_time_, '%Y-%m-%d' ) IN
  393. <foreach collection="days" item="day" separator="," open="(" close=")" >
  394. #{day}
  395. </foreach>
  396. OR DATE_FORMAT( exam_end_time_, '%Y-%m-%d' ) IN
  397. <foreach collection="days" item="day" separator="," open="(" close=")" >
  398. #{day}
  399. </foreach>
  400. </select>
  401. <select id="getWithExamAndSubject" resultMap="ExamRoom">
  402. SELECT * FROM exam_room WHERE examination_basic_id_=#{examId} AND FIND_IN_SET(#{subjectId}, subject_id_list_);
  403. </select>
  404. <select id="getExamRoomExamTime" resultType="com.keao.edu.user.dto.ExamRoomExamTimeDto">
  405. SELECT
  406. MIN(exam_start_time_) examStartTime,
  407. MAX(exam_end_time_) examEndTime
  408. FROM exam_room WHERE examination_basic_id_=#{examId}
  409. </select>
  410. </mapper>