ExamRoomMapper.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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" />
  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_time_json_" property="examTimeJson" />
  17. <result column="del_flag_" property="delFlag" />
  18. <result column="create_time_" property="createTime" />
  19. <result column="update_time_" property="updateTime" />
  20. <result column="tenant_id_" property="tenantId" />
  21. </resultMap>
  22. <!-- 根据主键查询一条记录 -->
  23. <select id="get" resultMap="ExamRoom" >
  24. SELECT * FROM exam_room WHERE id_ = #{id}
  25. </select>
  26. <!-- 全查询 -->
  27. <select id="findAll" resultMap="ExamRoom">
  28. SELECT * FROM exam_room ORDER BY id_
  29. </select>
  30. <!-- 向数据库增加一条记录 -->
  31. <insert id="insert" parameterType="com.keao.edu.user.api.entity.ExamRoom" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  32. INSERT INTO exam_room (id_,examination_basic_id_,exam_mode_,exam_location_id_,subject_id_list_,main_teacher_user_id_,
  33. assistant_teacher_user_id_list_,exam_time_json_,del_flag_,create_time_,update_time_,tenant_id_)
  34. VALUES(#{id},#{examinationBasicId},#{examMode},#{examLocationId},#{subjectIdList},#{mainTeacherUserId},#{assistantTeacherUserIdList},
  35. #{examTimeJson},#{delFlag},NOW(),NOW(),#{tenantId})
  36. </insert>
  37. <!-- 根据主键查询一条记录 -->
  38. <update id="update" parameterType="com.keao.edu.user.api.entity.ExamRoom">
  39. UPDATE exam_room
  40. <set>
  41. <if test="delFlag != null">
  42. del_flag_ = #{delFlag},
  43. </if>
  44. <if test="examinationBasicId != null">
  45. examination_basic_id_ = #{examinationBasicId},
  46. </if>
  47. <if test="examTimeJson != null">
  48. exam_time_json_ = #{examTimeJson},
  49. </if>
  50. <if test="subjectIdList != null">
  51. subject_id_list_ = #{subjectIdList},
  52. </if>
  53. <if test="tenantId != null">
  54. tenant_id_ = #{tenantId},
  55. </if>
  56. <if test="examMode != null">
  57. exam_mode_ = #{examMode},
  58. </if>
  59. <if test="examLocationId != null">
  60. exam_location_id_ = #{examLocationId},
  61. </if>
  62. <if test="mainTeacherUserId != null">
  63. main_teacher_user_id_ = #{mainTeacherUserId},
  64. </if>
  65. <if test="assistantTeacherUserIdList != null">
  66. assistant_teacher_user_id_list_ = #{assistantTeacherUserIdList},
  67. </if>
  68. update_time_ = NOW()
  69. </set> WHERE id_ = #{id}
  70. </update>
  71. <!-- 根据主键删除一条记录 -->
  72. <delete id="delete" >
  73. DELETE FROM exam_room WHERE id_ = #{id}
  74. </delete>
  75. <delete id="batchDeleteExamRooms">
  76. DELETE FROM exam_room WHERE id_ IN
  77. <foreach collection="examRoomIds" item="examRoomId" separator="," open="(" close=")">
  78. #{examRoomId}
  79. </foreach>
  80. </delete>
  81. <!-- 分页查询 -->
  82. <select id="queryPage" resultMap="ExamRoom" parameterType="map">
  83. SELECT * FROM exam_room ORDER BY id_ <include refid="global.limit"/>
  84. </select>
  85. <!-- 查询当前表的总记录数 -->
  86. <select id="queryCount" resultType="int">
  87. SELECT COUNT(*) FROM exam_room
  88. </select>
  89. <sql id="queryExamRoomPageSql">
  90. <where>
  91. <if test="examRoomId!=null">
  92. er.id_=#{examRoomId}
  93. </if>
  94. <if test="examId!=null">
  95. AND er.examination_basic_id_ = #{examId}
  96. </if>
  97. <if test="tenantId != null">
  98. AND er.tenant_id_ = #{tenantId}
  99. </if>
  100. <if test="startTime != null">
  101. AND eb.expect_exam_start_time_ >= #{startTime}
  102. </if>
  103. <if test="endTime != null">
  104. AND eb.expect_exam_end_time_ &lt;= #{endTime}
  105. </if>
  106. <if test="search != null and search != ''">
  107. AND eb.name_ LIKE CONCAT('%',#{search},'%')
  108. </if>
  109. <if test="examStatusEnum != null and examStatusEnum != ''">
  110. AND eb.status_ = #{examStatusEnum}
  111. </if>
  112. </where>
  113. </sql>
  114. <resultMap type="com.keao.edu.user.dto.ExamRoomDto" id="ExamRoomDto" extends="ExamRoom">
  115. <association property="examLocation" javaType="com.keao.edu.user.entity.ExamLocation" resultMap="com.keao.edu.user.dao.ExamLocationDao.ExamLocation"/>
  116. <association property="examinationBasic" javaType="com.keao.edu.user.entity.ExaminationBasic" resultMap="com.keao.edu.user.dao.ExaminationBasicDao.ExaminationBasic"/>
  117. </resultMap>
  118. <select id="countExamRoomPage" resultType="java.lang.Integer">
  119. SELECT COUNT(er.id_) FROM exam_room er
  120. LEFT JOIN exam_location el ON er.exam_location_id_ = el.id_ AND er.tenant_id_ = el.tenant_id_
  121. 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_
  122. <include refid="queryExamRoomPageSql"/>
  123. </select>
  124. <select id="queryExamRoomPage" resultMap="ExamRoomDto">
  125. SELECT er.*,eb.* FROM exam_room er
  126. LEFT JOIN exam_location el ON er.exam_location_id_ = el.id_ AND er.tenant_id_ = el.tenant_id_
  127. 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_
  128. <include refid="queryExamRoomPageSql"/>
  129. ORDER BY eb.expect_exam_start_time_ DESC
  130. <include refid="global.limit"/>
  131. </select>
  132. </mapper>