DegreeRegistrationMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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. <mapper namespace="com.ym.mec.biz.dal.dao.DegreeRegistrationDao">
  4. <resultMap id="DegreeRegistration" type="com.ym.mec.biz.dal.entity.DegreeRegistration">
  5. <!--@mbg.generated-->
  6. <!--@Table degree_registration-->
  7. <id column="id_" jdbcType="INTEGER" property="id"/>
  8. <result column="user_id_" property="userId"/>
  9. <result column="degree_id_" property="degreeId"/>
  10. <result column="organ_id_" jdbcType="INTEGER" property="organId"/>
  11. <result column="order_no_" jdbcType="VARCHAR" property="orderNo"/>
  12. <result column="trans_no_" jdbcType="VARCHAR" property="transNo"/>
  13. <result column="name_" jdbcType="VARCHAR" property="name"/>
  14. <result column="gender_" jdbcType="VARCHAR" property="gender"/>
  15. <result column="idcard_" jdbcType="VARCHAR" property="idcard"/>
  16. <result column="city_" jdbcType="VARCHAR" property="city"/>
  17. <result column="school_" jdbcType="VARCHAR" property="school"/>
  18. <result column="subject_id_" property="subjectId"/>
  19. <result column="level_" jdbcType="VARCHAR" property="level"/>
  20. <result column="theory_cert_" jdbcType="VARCHAR" property="theoryCert"/>
  21. <result column="mobile_" jdbcType="VARCHAR" property="mobile"/>
  22. <result column="money_" jdbcType="DECIMAL" property="money"/>
  23. <result column="memo_" jdbcType="VARCHAR" property="memo"/>
  24. <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
  25. <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
  26. <result column="status_" jdbcType="TINYINT" property="status"/>
  27. <result column="certificate_type_" property="certificateType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  28. <result column="tenant_id_" property="tenantId" />
  29. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  30. </resultMap>
  31. <select id="get" parameterType="java.lang.Integer" resultMap="DegreeRegistration">
  32. select *
  33. from degree_registration
  34. where id_ = #{id,jdbcType=INTEGER}
  35. </select>
  36. <!-- 全查询 -->
  37. <select id="findAll" resultMap="DegreeRegistration">
  38. SELECT *
  39. FROM degree_registration where tenant_id_ = #{tenantId}
  40. ORDER BY id_
  41. </select>
  42. <sql id="queryPageSql">
  43. <where>
  44. tenant_id_ = #{tenantId}
  45. <if test="organId != null and organId != ''">
  46. AND FIND_IN_SET(organ_id_,#{organId})
  47. </if>
  48. <if test="type != null">
  49. AND type_ = #{type}
  50. </if>
  51. <if test="status != null">
  52. AND status_ = #{status}
  53. </if>
  54. <if test="degreeType != null">
  55. AND degree_type_ = #{degreeType}
  56. </if>
  57. <if test="id != null">
  58. AND id_ = #{id}
  59. </if>
  60. <if test="orderNo != null">
  61. AND order_no_ = #{orderNo}
  62. </if>
  63. <if test="transNo != null">
  64. AND trans_no_ = #{transNo}
  65. </if>
  66. <if test="name != null">
  67. AND name_ = #{name}
  68. </if>
  69. <if test="idcard != null">
  70. AND idcard_ = #{idcard}
  71. </if>
  72. <if test="school != null">
  73. AND school_ LIKE CONCAT('%', #{school},'%')
  74. </if>
  75. <if test="city != null">
  76. AND city_ LIKE CONCAT('%', #{city},'%')
  77. </if>
  78. <if test="subject != null">
  79. AND subject_ = #{subject}
  80. </if>
  81. <if test="subjectId != null">
  82. AND subject_id_= #{subjectId}
  83. </if>
  84. <if test="mobile != null">
  85. AND mobile_= #{mobile}
  86. </if>
  87. <if test="level != null and level != ''">
  88. AND level_= #{level}
  89. </if>
  90. <if test="startTime != null">
  91. AND DATE_FORMAT(create_time_,"%Y-%m-%d") >= #{startTime}
  92. </if>
  93. <if test="endTime != null">
  94. <![CDATA[AND DATE_FORMAT(create_time_,"%Y-%m-%d") <= #{endTime}]]>
  95. </if>
  96. <if test="search != null and search != ''">
  97. and (user_id_ like concat('%',#{search},'%') or name_ like CONCAT('%',#{search},'%') or mobile_ like CONCAT('%',#{search},'%') )
  98. </if>
  99. <if test="degreeId != null ">
  100. and degree_id_ = #{degreeId}
  101. </if>
  102. </where>
  103. </sql>
  104. <!-- 分页查询 -->
  105. <select id="queryPage" resultMap="DegreeRegistration" parameterType="map">
  106. SELECT * FROM degree_registration
  107. <include refid="queryPageSql"/>
  108. <include refid="global.orderby"/>
  109. <include refid="global.limit"/>
  110. </select>
  111. <!-- 查询当前表的总记录数 -->
  112. <select id="queryCount" resultType="int">
  113. SELECT COUNT(*)
  114. FROM degree_registration
  115. <include refid="queryPageSql"/>
  116. </select>
  117. <select id="getTotalAmount" parameterType="map" resultMap="DegreeRegistration">
  118. SELECT SUM(case when status_ = 2 then money_ else 0 end) money_ FROM degree_registration
  119. <include refid="queryPageSql"/>
  120. </select>
  121. <select id="countApplyNum" parameterType="map" resultType="int">
  122. SELECT COUNT(DISTINCT user_id_)
  123. FROM degree_registration
  124. <include refid="queryPageSql"/>
  125. </select>
  126. <delete id="delete" parameterType="java.lang.Integer">
  127. delete
  128. from degree_registration
  129. where id_ = #{id,jdbcType=INTEGER}
  130. </delete>
  131. <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.DegreeRegistration"
  132. useGeneratedKeys="true">
  133. <!--@mbg.generated-->
  134. insert into degree_registration (user_id_,degree_id_,organ_id_,order_no_, name_, gender_,
  135. idcard_, city_, school_,
  136. subject_id_,level_, theory_cert_,mobile_,
  137. money_, memo_,status_,certificate_type_,tenant_id_,type_)
  138. values (#{userId},#{degreeId},#{organId,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{gender,jdbcType=VARCHAR},
  139. #{idcard,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, #{school,jdbcType=VARCHAR},
  140. #{subjectId},#{level,jdbcType=VARCHAR},
  141. #{theoryCert,jdbcType=VARCHAR},#{mobile,jdbcType=VARCHAR},#{money,jdbcType=DECIMAL}, #{memo,jdbcType=VARCHAR},
  142. #{status,jdbcType=TINYINT},#{certificateType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  143. #{tenantId},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  144. </insert>
  145. <insert id="batchInsert">
  146. INSERT INTO degree_registration (user_id_,degree_id_,organ_id_,order_no_, name_, gender_,
  147. idcard_, city_, school_,
  148. subject_id_,level_, theory_cert_,mobile_,
  149. money_, memo_,status_,certificate_type_,tenant_id_,type_)
  150. VALUE
  151. <foreach collection="degreeRegistrationList" separator="," item="degreeRegistration">
  152. (#{degreeRegistration.userId},#{degreeRegistration.degreeId,jdbcType=INTEGER},#{degreeRegistration.organId,jdbcType=INTEGER},
  153. #{degreeRegistration.orderNo,jdbcType=VARCHAR}, #{degreeRegistration.name,jdbcType=VARCHAR}, #{degreeRegistration.gender,jdbcType=VARCHAR},
  154. #{degreeRegistration.idcard,jdbcType=VARCHAR}, #{degreeRegistration.city,jdbcType=VARCHAR}, #{degreeRegistration.school,jdbcType=VARCHAR},
  155. #{degreeRegistration.subjectId},#{degreeRegistration.level,jdbcType=VARCHAR},
  156. #{degreeRegistration.theoryCert,jdbcType=VARCHAR},#{degreeRegistration.mobile,jdbcType=VARCHAR},#{degreeRegistration.money,jdbcType=DECIMAL}, #{degreeRegistration.memo,jdbcType=VARCHAR},
  157. #{degreeRegistration.status,jdbcType=TINYINT},
  158. #{degreeRegistration.certificateType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  159. #{degreeRegistration.tenantId},#{degreeRegistration.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  160. </foreach>
  161. </insert>
  162. <update id="update" parameterType="com.ym.mec.biz.dal.entity.DegreeRegistration">
  163. <!--@mbg.generated-->
  164. update degree_registration
  165. <set>
  166. <if test="userId != null">
  167. user_id_ = #{userId},
  168. </if>
  169. <if test="organId != null">
  170. organ_id_ = #{organId,jdbcType=INTEGER},
  171. </if>
  172. <if test="degreeId != null">
  173. degree_id_ = #{degreeId},
  174. </if>
  175. <if test="orderNo != null">
  176. order_no_ = #{orderNo,jdbcType=VARCHAR},
  177. </if>
  178. <if test="transNo != null">
  179. trans_no_ = #{transNo,jdbcType=VARCHAR},
  180. </if>
  181. <if test="name != null">
  182. name_ = #{name,jdbcType=VARCHAR},
  183. </if>
  184. <if test="gender != null">
  185. gender_ = #{gender,jdbcType=VARCHAR},
  186. </if>
  187. <if test="idcard != null">
  188. idcard_ = #{idcard,jdbcType=VARCHAR},
  189. </if>
  190. <if test="city != null">
  191. city_ = #{city,jdbcType=VARCHAR},
  192. </if>
  193. <if test="school != null">
  194. school_ = #{school,jdbcType=VARCHAR},
  195. </if>
  196. <if test="subjectId != null">
  197. subject_id_ = #{subjectId},
  198. </if>
  199. <if test="level != null">
  200. level_ = #{level,jdbcType=VARCHAR},
  201. </if>
  202. <if test="theoryCert != null and theoryCert != ''">
  203. theory_cert_ = #{theoryCert,jdbcType=VARCHAR},
  204. </if>
  205. <if test="mobile != null">
  206. mobile_ = #{mobile,jdbcType=VARCHAR},
  207. </if>
  208. <if test="money != null">
  209. money_ = #{money,jdbcType=DECIMAL},
  210. </if>
  211. <if test="memo != null">
  212. memo_ = #{memo,jdbcType=VARCHAR},
  213. </if>
  214. <if test="status != null">
  215. status_ = #{status,jdbcType=INTEGER},
  216. </if>
  217. <if test="certificateType != null">
  218. certificate_type_ = #{certificateType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  219. </if>
  220. </set>
  221. where id_ = #{id,jdbcType=INTEGER} and tenant_id_ = #{tenantId}
  222. </update>
  223. <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.DegreeRegistration">
  224. <foreach collection="degrees" item="degree" separator=";">
  225. update degree_registration
  226. <set>
  227. <if test="degree.userId != null">
  228. user_id_ = #{degree.userId},
  229. </if>
  230. <if test="degree.organId != null">
  231. organ_id_ = #{degree.organId,jdbcType=INTEGER},
  232. </if>
  233. <if test="degree.degreeId != null">
  234. degree_id_ = #{degree.degreeId},
  235. </if>
  236. <if test="degree.orderNo != null">
  237. order_no_ = #{degree.orderNo,jdbcType=VARCHAR},
  238. </if>
  239. <if test="degree.transNo != null">
  240. trans_no_ = #{degree.transNo,jdbcType=VARCHAR},
  241. </if>
  242. <if test="degree.name != null">
  243. name_ = #{degree.name,jdbcType=VARCHAR},
  244. </if>
  245. <if test="degree.gender != null">
  246. gender_ = #{degree.gender,jdbcType=VARCHAR},
  247. </if>
  248. <if test="degree.idcard != null">
  249. idcard_ = #{degree.idcard,jdbcType=VARCHAR},
  250. </if>
  251. <if test="degree.city != null">
  252. city_ = #{degree.city,jdbcType=VARCHAR},
  253. </if>
  254. <if test="degree.school != null">
  255. school_ = #{degree.school,jdbcType=VARCHAR},
  256. </if>
  257. <if test="degree.subjectId != null">
  258. subject_id_ = #{degree.subjectId},
  259. </if>
  260. <if test="degree.level != null">
  261. level_ = #{degree.level,jdbcType=VARCHAR},
  262. </if>
  263. <if test="degree.theoryCert != null and degree.theoryCert != ''">
  264. theory_cert_ = #{degree.theoryCert,jdbcType=VARCHAR},
  265. </if>
  266. <if test="degree.mobile != null">
  267. mobile_ = #{degree.mobile,jdbcType=VARCHAR},
  268. </if>
  269. <if test="degree.money != null">
  270. money_ = #{degree.money,jdbcType=DECIMAL},
  271. </if>
  272. <if test="degree.memo != null">
  273. memo_ = #{degree.memo,jdbcType=VARCHAR},
  274. </if>
  275. <if test="degree.status != null">
  276. status_ = #{degree.status,jdbcType=INTEGER},
  277. </if>
  278. <if test="degree.certificateType != null">
  279. certificate_type_ = #{degree.certificateType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  280. </if>
  281. </set>
  282. where id_ = #{degree.id,jdbcType=INTEGER} and tenant_id_ = #{degree.tenantId}
  283. </foreach>
  284. </update>
  285. <select id="findByMobileAndSporadicId" resultMap="DegreeRegistration">
  286. SELECT *
  287. FROM degree_registration
  288. WHERE mobile_ = #{mobile}
  289. AND sporadic_id_ = #{sporadicId} FOR
  290. UPDATE
  291. </select>
  292. <select id="getLock" resultMap="DegreeRegistration">
  293. SELECT *
  294. FROM degree_registration
  295. WHERE id_ = #{id} FOR
  296. UPDATE
  297. </select>
  298. <select id="getWithUserIdAndActivityTag" resultMap="DegreeRegistration">
  299. select *
  300. from degree_registration
  301. where
  302. user_id_ = #{degree.userId}
  303. AND activity_tag_=#{degree.activityTag}
  304. <if test="degree.subject!=null and degree.subject!=''">
  305. AND subject_ = #{degree.subject}
  306. </if>
  307. <if test="degree.sporadicId!=null">
  308. AND sporadic_id_ = #{degree.sporadicId}
  309. </if>
  310. <if test="degree.degreeType != null">
  311. AND degree_type_ = #{degree.degreeType}
  312. </if>
  313. </select>
  314. <select id="getUserLevelDegrees" resultMap="DegreeRegistration">
  315. select * from degree_registration
  316. where user_id_ = #{userId} and degree_id_ = #{degreeId} and type_ = #{type}
  317. AND FIND_IN_SET(level_,#{levels}) AND subject_id_ = #{subjectId} AND status_ = 2 LIMIT 1
  318. </select>
  319. <select id="getLockByOrderId" resultMap="DegreeRegistration">
  320. SELECT * FROM degree_registration WHERE order_no_ = #{orderNo} FOR UPDATE
  321. </select>
  322. <select id="findByByOrderId" resultMap="DegreeRegistration">
  323. SELECT * FROM degree_registration WHERE order_no_ = #{orderNo}
  324. </select>
  325. <select id="selectByDegreeId" resultMap="DegreeRegistration">
  326. SELECT *
  327. FROM degree_registration
  328. WHERE degree_id_ = #{degreeId}
  329. AND status_ = 1
  330. </select>
  331. </mapper>