ExaminationBasicMapper.xml 9.4 KB

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