ExaminationBasicMapper.xml 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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.ExaminationBasicDao">
  8. <resultMap type="com.keao.edu.user.entity.ExaminationBasic" id="ExaminationBasic">
  9. <result column="id_" property="id" />
  10. <result column="name_" property="name" />
  11. <result column="exam_mode_" property="examMode" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler" />
  12. <result column="exam_location_id_list_" property="examLocationIdList" />
  13. <result column="exam_location_name_list_" property="examLocationNameList" />
  14. <result column="status_" property="status" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler" />
  15. <result column="enroll_start_time_" property="enrollStartTime" />
  16. <result column="enroll_end_time_" property="enrollEndTime" />
  17. <result column="expect_exam_start_time_" property="expectExamStartTime" />
  18. <result column="expect_exam_end_time_" property="expectExamEndTime" />
  19. <result column="actual_exam_start_time_" property="actualExamStartTime" />
  20. <result column="actual_exam_end_time_" property="actualExamEndTime" />
  21. <result column="poster_title_" property="posterTitle" />
  22. <result column="poster_profile_" property="posterProfile" />
  23. <result column="poster_background_img_" property="posterBackgroundImg" />
  24. <result column="custom_poster_" property="customPoster"/>
  25. <result column="create_time_" property="createTime" />
  26. <result column="update_time_" property="updateTime" />
  27. <result column="tenant_id_" property="tenantId" />
  28. <result column="memo_" property="memo" />
  29. <result column="organ_id_" property="organId"/>
  30. <result column="creator_id_" property="creatorId"/>
  31. </resultMap>
  32. <resultMap id="ExaminationBasicDto" type="com.keao.edu.user.dto.ExaminationBasicDto" extends="ExaminationBasic">
  33. </resultMap>
  34. <!-- 根据主键查询一条记录 -->
  35. <select id="get" resultMap="ExaminationBasic" >
  36. SELECT * FROM examination_basic WHERE id_ = #{id}
  37. </select>
  38. <select id="getExaminationBasic" resultMap="ExaminationBasicDto" >
  39. SELECT * FROM examination_basic WHERE id_ = #{examId}
  40. </select>
  41. <!-- 全查询 -->
  42. <select id="findAll" resultMap="ExaminationBasic">
  43. SELECT * FROM examination_basic WHERE tenant_id_=#{tenantId}
  44. </select>
  45. <!-- 向数据库增加一条记录 -->
  46. <insert id="insert" parameterType="com.keao.edu.user.entity.ExaminationBasic" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  47. INSERT INTO examination_basic (id_,name_,exam_mode_,exam_location_id_list_,exam_location_name_list_,status_,enroll_start_time_,enroll_end_time_,
  48. expect_exam_start_time_,expect_exam_end_time_,actual_exam_start_time_,actual_exam_end_time_,
  49. poster_title_,poster_profile_,poster_background_img_,custom_poster_,creator_id_,create_time_,update_time_,tenant_id_,memo_,organ_id_)
  50. VALUES(#{id},#{name},#{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{examLocationIdList},#{examLocationNameList},
  51. #{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{enrollStartTime},#{enrollEndTime},
  52. #{expectExamStartTime},#{expectExamEndTime},#{actualExamStartTime},#{actualExamEndTime},
  53. #{posterTitle},#{posterProfile},#{posterBackgroundImg},#{customPoster},#{creatorId},NOW(),NOW(),#{tenantId},#{memo},#{organId})
  54. </insert>
  55. <update id="update" parameterType="com.keao.edu.user.entity.ExamOrganizationRelation">
  56. UPDATE examination_basic
  57. <set>
  58. <if test="name != null">
  59. name_ = #{name},
  60. </if>
  61. <if test="examMode != null">
  62. exam_mode_ = #{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  63. </if>
  64. <if test="examLocationIdList != null">
  65. exam_location_id_list_ = #{examLocationIdList},
  66. </if>
  67. <if test="examLocationNameList != null">
  68. exam_location_name_list_ = #{examLocationNameList},
  69. </if>
  70. <if test="status != null">
  71. status_ = #{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  72. </if>
  73. <if test="enrollStartTime != null">
  74. enroll_start_time_ = #{enrollStartTime},
  75. </if>
  76. <if test="enrollEndTime != null">
  77. enroll_end_time_ = #{enrollEndTime},
  78. </if>
  79. <if test="expectExamStartTime != null">
  80. expect_exam_start_time_ = #{expectExamStartTime},
  81. </if>
  82. <if test="expectExamEndTime != null">
  83. expect_exam_end_time_ = #{expectExamEndTime},
  84. </if>
  85. actual_exam_start_time_ = #{actualExamStartTime},
  86. actual_exam_end_time_ = #{actualExamEndTime},
  87. <if test="posterTitle != null">
  88. poster_title_ = #{posterTitle},
  89. </if>
  90. <if test="posterProfile != null">
  91. poster_profile_ = #{posterProfile},
  92. </if>
  93. poster_background_img_ = #{posterBackgroundImg},
  94. custom_poster_ = #{customPoster},
  95. <if test="tenantId != null">
  96. tenant_id_ = #{tenantId},
  97. </if>
  98. <if test="memo!=null">
  99. memo_=#{memo},
  100. </if>
  101. <if test="creatorId!=null">
  102. creator_id_=#{creatorId},
  103. </if>
  104. update_time_ = NOW()
  105. </set> WHERE id_ = #{id}
  106. </update>
  107. <update id="batchUpdate" parameterType="com.keao.edu.user.entity.ExamOrganizationRelation">
  108. <foreach collection="exams" item="exam" separator=";">
  109. UPDATE examination_basic
  110. <set>
  111. <if test="exam.name != null">
  112. name_ = #{exam.name},
  113. </if>
  114. <if test="exam.examMode != null">
  115. exam_mode_ = #{exam.examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  116. </if>
  117. <if test="exam.examLocationIdList != null">
  118. exam_location_id_list_ = #{exam.examLocationIdList},
  119. </if>
  120. <if test="exam.examLocationNameList != null">
  121. exam_location_name_list_ = #{exam.examLocationNameList},
  122. </if>
  123. <if test="exam.status != null">
  124. status_ = #{exam.status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  125. </if>
  126. <if test="exam.enrollStartTime != null">
  127. enroll_start_time_ = #{exam.enrollStartTime},
  128. </if>
  129. <if test="exam.enrollEndTime != null">
  130. enroll_end_time_ = #{exam.enrollEndTime},
  131. </if>
  132. <if test="exam.expectExamStartTime != null">
  133. expect_exam_start_time_ = #{exam.expectExamStartTime},
  134. </if>
  135. <if test="exam.expectExamEndTime != null">
  136. expect_exam_end_time_ = #{exam.expectExamEndTime},
  137. </if>
  138. actual_exam_start_time_ = #{exam.actualExamStartTime},
  139. actual_exam_end_time_ = #{exam.actualExamEndTime},
  140. <if test="exam.posterTitle != null">
  141. poster_title_ = #{exam.posterTitle},
  142. </if>
  143. <if test="exam.posterProfile != null">
  144. poster_profile_ = #{exam.posterProfile},
  145. </if>
  146. <if test="exam.posterBackgroundImg != null">
  147. poster_background_img_ = #{exam.posterBackgroundImg},
  148. </if>
  149. <if test="exam.customPoster != null">
  150. custom_poster_ = #{exam.customPoster},
  151. </if>
  152. <if test="exam.tenantId != null">
  153. tenant_id_ = #{exam.tenantId},
  154. </if>
  155. <if test="exam.memo!=null">
  156. memo_=#{exam.memo},
  157. </if>
  158. <if test="exam.creatorId!=null">
  159. creator_id_=#{exam.creatorId},
  160. </if>
  161. update_time_ = NOW()
  162. </set> WHERE id_ = #{exam.id}
  163. </foreach>
  164. </update>
  165. <!-- 根据主键删除一条记录 -->
  166. <delete id="delete" >
  167. DELETE FROM examination_basic WHERE id_ = #{id}
  168. </delete>
  169. <sql id="queryCondition">
  170. <where>
  171. <if test="organIds!=null">
  172. AND organ_id_ IN
  173. <foreach collection="organIds" item="organId" separator="," open="(" close=")">
  174. #{organId}
  175. </foreach>
  176. </if>
  177. <if test="examStatus!=null">
  178. AND status_=#{examStatus}
  179. </if>
  180. <if test="search!=null">
  181. AND (id_=#{search} OR name_ LIKE CONCAT('%', #{search}, '%'))
  182. </if>
  183. </where>
  184. </sql>
  185. <!-- 分页查询 -->
  186. <select id="queryPage" resultMap="ExaminationBasic" parameterType="map">
  187. SELECT * FROM examination_basic
  188. <include refid="queryCondition"/>
  189. <include refid="global.limit"/>
  190. </select>
  191. <!-- 查询当前表的总记录数 -->
  192. <select id="queryCount" resultType="int">
  193. SELECT COUNT(*) FROM examination_basic
  194. <include refid="queryCondition"/>
  195. </select>
  196. <sql id="findExaminationBasicsCondition">
  197. <where>
  198. eb.status_!='DELETE'
  199. <if test="organId!=null">
  200. AND eor.organ_id_ = #{organId}
  201. </if>
  202. <if test="examStatus!=null">
  203. AND eb.status_=#{examStatus}
  204. </if>
  205. <if test="search!=null">
  206. AND (eb.id_=#{search} OR eb.name_ LIKE CONCAT('%', #{search}, '%'))
  207. </if>
  208. </where>
  209. </sql>
  210. <select id="findExaminationBasics" resultMap="ExaminationBasicDto" parameterType="map">
  211. SELECT DISTINCT eb.*
  212. FROM
  213. exam_organization_relation eor
  214. LEFT JOIN examination_basic eb ON eor.examination_basic_id_ = eb.id_
  215. <include refid="findExaminationBasicsCondition"/>
  216. ORDER BY id_ DESC
  217. <include refid="global.limit"/>
  218. </select>
  219. <select id="countExaminationBasics" resultType="int">
  220. SELECT COUNT(DISTINCT eb.id_)
  221. FROM
  222. exam_organization_relation eor
  223. LEFT JOIN examination_basic eb ON eor.examination_basic_id_ = eb.id_
  224. <include refid="findExaminationBasicsCondition"/>
  225. </select>
  226. <select id="getNeedUpdateStatusExams" resultMap="ExaminationBasic">
  227. SELECT * FROM examination_basic WHERE status_ IN ('NOT_START', 'APPLYING', 'APPLIED', 'EXAM_ING')
  228. </select>
  229. <select id="getExams" resultMap="ExaminationBasicDto">
  230. SELECT * FROM examination_basic
  231. WHERE id_ IN
  232. <foreach collection="examIds" item="examId" separator="," open="(" close=")">
  233. #{examId}
  234. </foreach>
  235. </select>
  236. <select id="lockExam" resultMap="ExaminationBasic">
  237. SELECT
  238. id_,
  239. name_,
  240. exam_mode_,
  241. exam_location_id_list_,
  242. status_,
  243. enroll_start_time_,
  244. enroll_end_time_,
  245. expect_exam_start_time_,
  246. expect_exam_end_time_,
  247. poster_title_,
  248. poster_profile_,
  249. poster_background_img_,
  250. memo_,
  251. create_time_,
  252. update_time_,
  253. tenant_id_,
  254. organ_id_,
  255. creator_id_,
  256. exam_location_name_list_,
  257. actual_exam_start_time_,
  258. actual_exam_end_time_
  259. FROM
  260. examination_basic
  261. WHERE
  262. id_ = #{examId} FOR UPDATE
  263. </select>
  264. <select id="getEndExamsWithDayAndStatus" resultMap="ExaminationBasic">
  265. SELECT * FROM examination_basic WHERE DATE_FORMAT(actual_exam_end_time_, '%Y-%m-%d') = #{day}
  266. </select>
  267. </mapper>