ExamRoomMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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="exam_plan_push_flag_" property="examPlanPushFlag" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
  24. <result column="exam_room_student_num_" property="examRoomStudentNum"/>
  25. <result column="create_time_" property="createTime" />
  26. <result column="update_time_" property="updateTime" />
  27. <result column="tenant_id_" property="tenantId" />
  28. </resultMap>
  29. <!-- 根据主键查询一条记录 -->
  30. <select id="get" resultMap="ExamRoom" >
  31. SELECT * FROM exam_room WHERE id_ = #{id}
  32. </select>
  33. <!-- 全查询 -->
  34. <select id="findAll" resultMap="ExamRoom">
  35. SELECT * FROM exam_room ORDER BY id_
  36. </select>
  37. <!-- 向数据库增加一条记录 -->
  38. <insert id="insert" parameterType="com.keao.edu.user.api.entity.ExamRoom" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  39. INSERT INTO exam_room (id_,examination_basic_id_,exam_mode_,exam_location_id_,subject_id_list_,subject_name_list_,
  40. main_teacher_user_id_,main_teacher_user_name_,assistant_teacher_user_id_list_,assistant_teacher_user_name_list_,
  41. exam_start_time_,exam_end_time_,del_flag_,organ_id_,exam_plan_push_flag_,
  42. exam_room_student_num_,create_time_,update_time_,tenant_id_)
  43. VALUES(#{id},#{examinationBasicId},#{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{examLocationId},
  44. #{subjectIdList},#{subjectNameList},#{mainTeacherUserId},#{mainTeacherName},#{assistantTeacherUserIdList},#{assistantTeacherUserNameList},
  45. #{examStartTime},#{examEndTime},#{delFlag},#{organId},#{examPlanPushFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  46. #{examRoomStudentNum},NOW(),NOW(),#{tenantId})
  47. </insert>
  48. <insert id="batchInsert" parameterType="com.keao.edu.user.api.entity.ExamRoom" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  49. INSERT INTO exam_room (examination_basic_id_,exam_mode_,exam_location_id_,subject_id_list_,subject_name_list_,
  50. main_teacher_user_id_,main_teacher_user_name_,assistant_teacher_user_id_list_,assistant_teacher_user_name_list_,
  51. exam_start_time_,exam_end_time_,del_flag_,organ_id_,exam_plan_push_flag_,
  52. exam_room_student_num_,create_time_,update_time_,tenant_id_)
  53. VALUES
  54. <foreach collection="examRooms" item="examRoom" separator=",">
  55. (#{examRoom.examinationBasicId},#{examRoom.examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{examRoom.examLocationId},
  56. #{examRoom.subjectIdList},#{examRoom.subjectNameList},
  57. #{examRoom.mainTeacherUserId},#{examRoom.mainTeacherName},#{examRoom.assistantTeacherUserIdList},#{examRoom.assistantTeacherUserNameList},
  58. #{examRoom.examStartTime},#{examRoom.examEndTime},#{examRoom.delFlag},#{examRoom.organId},#{examRoom.examPlanPushFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  59. #{examRoom.examRoomStudentNum},NOW(),NOW(),#{examRoom.tenantId})
  60. </foreach>
  61. </insert>
  62. <!-- 根据主键查询一条记录 -->
  63. <update id="update" parameterType="com.keao.edu.user.api.entity.ExamRoom">
  64. UPDATE exam_room
  65. <set>
  66. <if test="delFlag != null">
  67. del_flag_ = #{delFlag},
  68. </if>
  69. <if test="examinationBasicId != null">
  70. examination_basic_id_ = #{examinationBasicId},
  71. </if>
  72. <if test="examStartTime != null">
  73. exam_start_time_ = #{examStartTime},
  74. </if>
  75. <if test="examEndTime != null">
  76. exam_end_time_ = #{examEndTime},
  77. </if>
  78. <if test="subjectIdList != null">
  79. subject_id_list_ = #{subjectIdList},
  80. </if>
  81. <if test="subjectNameList != null">
  82. subject_name_list_ = #{subjectNameList},
  83. </if>
  84. <if test="tenantId != null and tenantId != 0">
  85. tenant_id_ = #{tenantId},
  86. </if>
  87. <if test="examMode != null">
  88. exam_mode_ = #{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  89. </if>
  90. <if test="examLocationId != null">
  91. exam_location_id_ = #{examLocationId},
  92. </if>
  93. <if test="mainTeacherUserId != null">
  94. main_teacher_user_id_ = #{mainTeacherUserId},
  95. </if>
  96. <if test="mainTeacherName != null">
  97. main_teacher_user_name_ = #{mainTeacherName},
  98. </if>
  99. <if test="assistantTeacherUserIdList != null">
  100. assistant_teacher_user_id_list_ = #{assistantTeacherUserIdList},
  101. </if>
  102. <if test="assistantTeacherUserNameList != null">
  103. assistant_teacher_user_name_list_ = #{assistantTeacherUserNameList},
  104. </if>
  105. <if test="organId != null">
  106. organ_id_ = #{organId},
  107. </if>
  108. <if test="examPlanPushFlag != null">
  109. exam_plan_push_flag_ = #{examPlanPushFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  110. </if>
  111. <if test="examRoomStudentNum!=null">
  112. exam_room_student_num_=#{examRoomStudentNum},
  113. </if>
  114. update_time_ = NOW()
  115. </set> WHERE id_ = #{id}
  116. </update>
  117. <update id="updateSL" parameterType="com.keao.edu.user.api.entity.ExamRoom">
  118. UPDATE exam_room
  119. <set>
  120. <if test="delFlag != null">
  121. del_flag_ = #{delFlag},
  122. </if>
  123. <if test="examinationBasicId != null">
  124. examination_basic_id_ = #{examinationBasicId},
  125. </if>
  126. <if test="examStartTime != null">
  127. exam_start_time_ = #{examStartTime},
  128. </if>
  129. <if test="examEndTime != null">
  130. exam_end_time_ = #{examEndTime},
  131. </if>
  132. <if test="subjectIdList != null">
  133. subject_id_list_ = #{subjectIdList},
  134. </if>
  135. <if test="subjectNameList != null">
  136. subject_name_list_ = #{subjectNameList},
  137. </if>
  138. <if test="tenantId != null and tenantId != 0">
  139. tenant_id_ = #{tenantId},
  140. </if>
  141. <if test="examMode != null">
  142. exam_mode_ = #{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  143. </if>
  144. <if test="examLocationId != null">
  145. exam_location_id_ = #{examLocationId},
  146. </if>
  147. <if test="mainTeacherUserId != null">
  148. main_teacher_user_id_ = #{mainTeacherUserId},
  149. </if>
  150. <if test="mainTeacherName != null">
  151. main_teacher_user_name_ = #{mainTeacherName},
  152. </if>
  153. <if test="assistantTeacherUserIdList != null">
  154. assistant_teacher_user_id_list_ = #{assistantTeacherUserIdList},
  155. </if>
  156. <if test="assistantTeacherUserNameList != null">
  157. assistant_teacher_user_name_list_ = #{assistantTeacherUserNameList},
  158. </if>
  159. <if test="organId != null">
  160. organ_id_ = #{organId},
  161. </if>
  162. <if test="examPlanPushFlag != null">
  163. exam_plan_push_flag_ = #{examPlanPushFlag,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  164. </if>
  165. <if test="examRoomStudentNum!=null">
  166. exam_room_student_num_=#{examRoomStudentNum},
  167. </if>
  168. update_time_ = NOW()
  169. </set> WHERE id_ = #{id} AND update_time_=#{updateTime}
  170. </update>
  171. <!-- 根据主键删除一条记录 -->
  172. <delete id="delete" >
  173. DELETE FROM exam_room WHERE id_ = #{id}
  174. </delete>
  175. <delete id="batchDeleteExamRooms">
  176. DELETE FROM exam_room WHERE exam_plan_push_flag_=0 AND id_ IN
  177. <foreach collection="examRoomIds" item="examRoomId" separator="," open="(" close=")">
  178. #{examRoomId}
  179. </foreach>
  180. </delete>
  181. <!-- 分页查询 -->
  182. <select id="queryPage" resultMap="ExamRoom" parameterType="map">
  183. SELECT * FROM exam_room ORDER BY id_ <include refid="global.limit"/>
  184. </select>
  185. <!-- 查询当前表的总记录数 -->
  186. <select id="queryCount" resultType="int">
  187. SELECT COUNT(*) FROM exam_room
  188. </select>
  189. <sql id="queryExamRoomPageSql">
  190. <where>
  191. <if test="organIds!=null">
  192. AND er.organ_id_ IN
  193. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  194. #{organId}
  195. </foreach>
  196. </if>
  197. <if test="examRoomId!=null">
  198. AND er.id_=#{examRoomId}
  199. </if>
  200. <if test="examId!=null">
  201. AND er.examination_basic_id_ = #{examId}
  202. </if>
  203. <if test="tenantId != null and tenantId != 0">
  204. AND er.tenant_id_ = #{tenantId}
  205. </if>
  206. <if test="startTime != null">
  207. AND eb.expect_exam_start_time_ >= #{startTime}
  208. </if>
  209. <if test="endTime != null">
  210. AND eb.expect_exam_end_time_ &lt;= #{endTime}
  211. </if>
  212. <if test="search != null and search != ''">
  213. AND eb.name_ LIKE CONCAT('%',#{search},'%')
  214. </if>
  215. <if test="examStatusEnum != null and examStatusEnum != ''">
  216. AND eb.status_ = #{examStatusEnum}
  217. </if>
  218. </where>
  219. </sql>
  220. <resultMap type="com.keao.edu.user.dto.ExamRoomDto" id="ExamRoomDto" extends="ExamRoom">
  221. <association property="examLocation" columnPrefix="el_" resultMap="com.keao.edu.user.dao.ExamLocationDao.ExamLocation"/>
  222. <association property="examinationBasic" columnPrefix="exam_" resultMap="com.keao.edu.user.dao.ExaminationBasicDao.ExaminationBasic"/>
  223. </resultMap>
  224. <select id="countExamRoomPage" resultType="java.lang.Integer">
  225. SELECT COUNT(er.id_) FROM exam_room er
  226. LEFT JOIN exam_location el ON er.exam_location_id_ = el.id_ AND er.tenant_id_ = el.tenant_id_
  227. 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_
  228. <include refid="queryExamRoomPageSql"/>
  229. </select>
  230. <select id="queryExamRoomPage" resultMap="ExamRoomDto">
  231. SELECT
  232. er.*,
  233. el.id_ el_id_,
  234. el.name_ el_name_,
  235. eb.name_ exam_name_
  236. FROM exam_room er
  237. LEFT JOIN exam_location el ON er.exam_location_id_ = el.id_ AND er.tenant_id_ = el.tenant_id_
  238. 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_
  239. <include refid="queryExamRoomPageSql"/>
  240. ORDER BY eb.expect_exam_start_time_ DESC
  241. <include refid="global.limit"/>
  242. </select>
  243. <sql id="queryExamRoomCondition">
  244. <where>
  245. <if test="organIds!=null">
  246. AND er.organ_id_ IN
  247. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  248. #{organId}
  249. </foreach>
  250. </if>
  251. <if test="examRoomId!=null">
  252. AND er.id_=#{examRoomId}
  253. </if>
  254. <if test="examId!=null">
  255. AND er.examination_basic_id_ = #{examId}
  256. </if>
  257. </where>
  258. </sql>
  259. <select id="queryExamRoom" resultMap="ExamRoomDto">
  260. SELECT
  261. er.*,
  262. el.id_ el_id_,
  263. el.name_ el_name_
  264. FROM exam_room er
  265. LEFT JOIN exam_location el ON er.exam_location_id_ = el.id_
  266. <include refid="queryExamRoomCondition"/>
  267. ORDER BY er.id_ DESC
  268. <include refid="global.limit"/>
  269. </select>
  270. <select id="countExamRoom" resultType="java.lang.Integer">
  271. SELECT COUNT(er.id_) FROM exam_room er
  272. LEFT JOIN exam_location el ON er.exam_location_id_ = el.id_
  273. <include refid="queryExamRoomCondition"/>
  274. </select>
  275. <select id="getWithExam" resultMap="ExamRoom">
  276. SELECT * FROM exam_room WHERE examination_basic_id_=#{examId}
  277. <if test="organIds!=null">
  278. AND organ_id_ IN
  279. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  280. #{organId}
  281. </foreach>
  282. </if>
  283. </select>
  284. <select id="lockRoom" resultMap="ExamRoom">
  285. SELECT * FROM exam_room WHERE id_=#{examRoomId} FOR UPDATE
  286. </select>
  287. <select id="getWithDays" resultMap="ExamRoom">
  288. SELECT
  289. *
  290. FROM
  291. exam_room
  292. WHERE
  293. DATE_FORMAT( exam_start_time_, '%Y-%m-%d' ) IN
  294. <foreach collection="days" item="day" separator="," open="(" close=")" >
  295. #{day}
  296. </foreach>
  297. OR DATE_FORMAT( exam_end_time_, '%Y-%m-%d' ) IN
  298. <foreach collection="days" item="day" separator="," open="(" close=")" >
  299. #{day}
  300. </foreach>
  301. </select>
  302. <select id="getWithExamAndSubject" resultMap="ExamRoom">
  303. SELECT * FROM exam_room WHERE examination_basic_id_=#{examId} AND FIND_IN_SET(#{subjectId}, subject_id_list_);
  304. </select>
  305. </mapper>