DegreeRegistrationMapper.xml 14 KB

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