DegreeRegistrationMapper.xml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. </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
  40. ORDER BY id_
  41. </select>
  42. <sql id="queryPageSql">
  43. <where>
  44. <if test="organId != null">
  45. AND FIND_IN_SET(organ_id_,#{organId})
  46. </if>
  47. <if test="status != null and status=='reg'">
  48. AND <![CDATA[status_ <= 1]]>
  49. </if>
  50. <if test="status != null and status=='pay'">
  51. AND status_ = 2
  52. </if>
  53. <if test="id != null">
  54. AND id_ = #{id}
  55. </if>
  56. <if test="search != null and search != ''">
  57. AND (id_ = #{search} OR name_ LIKE CONCAT('%',#{search},'%') )
  58. </if>
  59. <if test="orderNo != null">
  60. AND order_no_ = #{orderNo}
  61. </if>
  62. <if test="transNo != null">
  63. AND trans_no_ = #{transNo}
  64. </if>
  65. <if test="name != null">
  66. AND name_ = #{name}
  67. </if>
  68. <if test="idcard != null">
  69. AND idcard_ = #{idcard}
  70. </if>
  71. <if test="school != null">
  72. AND school_ LIKE CONCAT('%', #{school},'%')
  73. </if>
  74. <if test="city != null">
  75. AND city_ LIKE CONCAT('%', #{city},'%')
  76. </if>
  77. <if test="subject != null">
  78. AND subject_= #{subject}
  79. </if>
  80. <if test="mobile != null">
  81. AND mobile_= #{mobile}
  82. </if>
  83. <if test="level != null">
  84. AND level_= #{level}
  85. </if>
  86. <if test="startTime != null">
  87. AND DATE_FORMAT(create_time_,"%Y-%m-%d") >= #{startTime}
  88. </if>
  89. <if test="endTime != null">
  90. <![CDATA[AND DATE_FORMAT(create_time_,"%Y-%m-%d") <= #{endTime}]]>
  91. </if>
  92. </where>
  93. </sql>
  94. <!-- 分页查询 -->
  95. <select id="queryPage" resultMap="DegreeRegistration" parameterType="map">
  96. SELECT * FROM degree_registration
  97. <include refid="queryPageSql"/>
  98. <include refid="global.orderby"/>
  99. <include refid="global.limit"/>
  100. </select>
  101. <!-- 查询当前表的总记录数 -->
  102. <select id="queryCount" resultType="int">
  103. SELECT COUNT(*)
  104. FROM degree_registration
  105. <include refid="queryPageSql"/>
  106. </select>
  107. <select id="getTotalAmount" parameterType="map" resultMap="DegreeRegistration">
  108. 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
  109. <include refid="queryPageSql"/>
  110. </select>
  111. <delete id="delete" parameterType="java.lang.Integer">
  112. delete
  113. from degree_registration
  114. where id_ = #{id,jdbcType=INTEGER}
  115. </delete>
  116. <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.DegreeRegistration"
  117. useGeneratedKeys="true">
  118. <!--@mbg.generated-->
  119. insert into degree_registration (user_id_,sporadic_id_,organ_id_,order_no_, name_, gender_,
  120. idcard_, city_, school_,
  121. subject_,level_, theory_level_,theory_money_, theory_cert_,mobile_,
  122. money_, memo_, create_time_,
  123. update_time_, status_, activity_tag_)
  124. values (#{userId},#{sporadicId,jdbcType=INTEGER},#{organId,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{gender,jdbcType=VARCHAR},
  125. #{idcard,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, #{school,jdbcType=VARCHAR},
  126. #{subject,jdbcType=VARCHAR},#{level,jdbcType=VARCHAR},
  127. #{theoryLevel,jdbcType=VARCHAR},#{theoryMoney,jdbcType=DECIMAL},
  128. #{theoryCert,jdbcType=VARCHAR},#{mobile,jdbcType=VARCHAR},#{money,jdbcType=DECIMAL}, #{memo,jdbcType=VARCHAR},
  129. #{createTime}, #{updateTime}, #{status,jdbcType=TINYINT}, #{activityTag})
  130. </insert>
  131. <update id="update" parameterType="com.ym.mec.biz.dal.entity.DegreeRegistration">
  132. <!--@mbg.generated-->
  133. update degree_registration
  134. <set>
  135. <if test="userId != null">
  136. user_id_ = #{userId},
  137. </if>
  138. <if test="organId != null">
  139. organ_id_ = #{organId,jdbcType=INTEGER},
  140. </if>
  141. <if test="sporadicId != null">
  142. sporadic_id_ = #{sporadicId,jdbcType=INTEGER},
  143. </if>
  144. <if test="orderNo != null">
  145. order_no_ = #{orderNo,jdbcType=VARCHAR},
  146. </if>
  147. <if test="transNo != null">
  148. trans_no_ = #{transNo,jdbcType=VARCHAR},
  149. </if>
  150. <if test="name != null">
  151. name_ = #{name,jdbcType=VARCHAR},
  152. </if>
  153. <if test="gender != null">
  154. gender_ = #{gender,jdbcType=VARCHAR},
  155. </if>
  156. <if test="idcard != null">
  157. idcard_ = #{idcard,jdbcType=VARCHAR},
  158. </if>
  159. <if test="city != null">
  160. city_ = #{city,jdbcType=VARCHAR},
  161. </if>
  162. <if test="school != null">
  163. school_ = #{school,jdbcType=VARCHAR},
  164. </if>
  165. <if test="subject != null">
  166. subject_ = #{subject,jdbcType=VARCHAR},
  167. </if>
  168. <if test="level != null">
  169. level_ = #{level,jdbcType=VARCHAR},
  170. </if>
  171. <if test="theoryLevel != null">
  172. theory_level_ = #{theoryLevel,jdbcType=VARCHAR},
  173. </if>
  174. <if test="theoryLevel != null">
  175. theory_money_ = #{theoryMoney,jdbcType=DECIMAL},
  176. </if>
  177. <if test="theoryLevel != null">
  178. theory_cert_ = #{theoryCert,jdbcType=VARCHAR},
  179. </if>
  180. <if test="mobile != null">
  181. mobile_ = #{mobile,jdbcType=VARCHAR},
  182. </if>
  183. <if test="money != null">
  184. money_ = #{money,jdbcType=DECIMAL},
  185. </if>
  186. <if test="memo != null">
  187. memo_ = #{memo,jdbcType=VARCHAR},
  188. </if>
  189. <if test="createTime != null">
  190. create_time_ = #{createTime},
  191. </if>
  192. <if test="updateTime != null">
  193. update_time_ = #{updateTime},
  194. </if>
  195. <if test="status != null">
  196. status_ = #{status,jdbcType=INTEGER},
  197. </if>
  198. <if test="activityTag != null">
  199. activity_tag_ = #{activityTag},
  200. </if>
  201. </set>
  202. where id_ = #{id,jdbcType=INTEGER}
  203. </update>
  204. <select id="findByMobileAndSporadicId" resultMap="DegreeRegistration">
  205. SELECT *
  206. FROM degree_registration
  207. WHERE mobile_ = #{mobile}
  208. AND sporadic_id_ = #{sporadicId} FOR
  209. UPDATE
  210. </select>
  211. <select id="getLock" resultMap="DegreeRegistration">
  212. SELECT *
  213. FROM degree_registration
  214. WHERE id_ = #{id} FOR
  215. UPDATE
  216. </select>
  217. <select id="getWithUserIdAndActivityTag" resultMap="DegreeRegistration">
  218. select *
  219. from degree_registration
  220. where user_id_ = #{userId} AND activity_tag_=#{activityTag}
  221. </select>
  222. </mapper>