StudentRegistrationMapper.xml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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.ym.mec.biz.dal.dao.StudentRegistrationDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.StudentRegistration" id="StudentRegistration">
  9. <result column="id_" property="id"/>
  10. <result column="user_id_" property="userId"/>
  11. <result column="name_" property="name"/>
  12. <result column="music_group_id_" property="musicGroupId"/>
  13. <result column="current_grade_" property="currentGrade"/>
  14. <result column="current_class_" property="currentClass"/>
  15. <result column="subject_id_" property="subjectId"/>
  16. <result column="actual_subject_id_" property="actualSubjectId"/>
  17. <result column="is_allow_adjust_" property="isAllowAdjust"
  18. typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  19. <result column="kit_purchase_method_" property="kitPurchaseMethod"
  20. typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  21. <result column="remark_" property="remark"/>
  22. <result column="class_group_id_" property="classGroupId"/>
  23. <result column="create_time_" property="createTime"/>
  24. <result column="update_time_" property="updateTime"/>
  25. <result column="parents_name_" property="parentsName"/>
  26. <result column="parents_phone_" property="parentsPhone"/>
  27. <result column="parents_company_" property="parentsCompany"/>
  28. <result column="payment_status_" property="paymentStatus"
  29. typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  30. <result column="last_payment_date_" property="lastPaymentDate"/>
  31. <result column="next_payment_date_" property="nextPaymentDate"/>
  32. </resultMap>
  33. <!-- 根据主键查询一条记录 -->
  34. <select id="get" resultMap="StudentRegistration">
  35. SELECT * FROM student_registration WHERE id_ = #{id}
  36. </select>
  37. <!-- 全查询 -->
  38. <select id="findAll" resultMap="StudentRegistration">
  39. SELECT *
  40. FROM student_registration
  41. ORDER BY id_
  42. </select>
  43. <!-- 向数据库增加一条记录 -->
  44. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentRegistration" useGeneratedKeys="true"
  45. keyColumn="id" keyProperty="id">
  46. INSERT INTO student_registration
  47. (parents_phone_,id_,user_id_,name_,music_group_id_,current_grade_,current_class_,subject_id_,is_allow_adjust_,kit_purchase_method_,remark_,create_time_,update_time_,parents_name_,parents_company_,payment_status_,last_payment_date_,next_payment_date_,actual_subject_id_)
  48. VALUES(#{parentsPhone},#{id},#{userId},#{name},#{musicGroupId},#{currentGrade},#{currentClass},#{subjectId},#{isAllowAdjust,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{kitPurchaseMethod,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  49. #{remark},now(),now(),#{parentsName},#{parentsCompany},#{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{lastPaymentDate},#{nextPaymentDate},#{subjectId})
  50. </insert>
  51. <!-- 根据主键查询一条记录 -->
  52. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentRegistration">
  53. UPDATE student_registration
  54. <set>
  55. <if test="parentsPhone != null">
  56. parents_phone_ = #{parentsPhone},
  57. </if>
  58. <if test="subjectId != null">
  59. subject_id_ = #{subjectId},
  60. </if>
  61. <if test="nextPaymentDate != null">
  62. next_payment_date_ = #{nextPaymentDate},
  63. </if>
  64. <if test="currentGrade != null">
  65. current_grade_ = #{currentGrade},
  66. </if>
  67. <if test="lastPaymentDate != null">
  68. last_payment_date_ = #{lastPaymentDate},
  69. </if>
  70. <if test="currentClass != null">
  71. current_class_ = #{currentClass},
  72. </if>
  73. <if test="isAllowAdjust != null">
  74. is_allow_adjust_ = #{isAllowAdjust,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  75. </if>
  76. <if test="kitPurchaseMethod != null">
  77. kit_purchase_method_ = #{kitPurchaseMethod,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  78. </if>
  79. <if test="userId != null">
  80. user_id_ = #{userId},
  81. </if>
  82. <if test="name != null">
  83. name_ = #{name},
  84. </if>
  85. <if test="remark != null">
  86. remark_ = #{remark},
  87. </if>
  88. <if test="paymentStatus != null">
  89. payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  90. </if>
  91. <if test="parentsName != null">
  92. parents_name_ = #{parentsName},
  93. </if>
  94. <if test="updateTime != null">
  95. update_time_ = #{updateTime},
  96. </if>
  97. <if test="parentsCompany != null">
  98. parents_company_ = #{parentsCompany},
  99. </if>
  100. <if test="musicGroupId != null">
  101. music_group_id_ = #{musicGroupId},
  102. </if>
  103. <if test="actualSubjectId != null">
  104. actual_subject_id_ = #{actualSubjectId},
  105. </if>
  106. </set>
  107. WHERE id_ = #{id}
  108. </update>
  109. <!-- 根据主键删除一条记录 -->
  110. <delete id="delete">
  111. DELETE FROM student_registration WHERE id_ = #{id}
  112. </delete>
  113. <sql id="queryPageSql">
  114. <where>
  115. <if test="isAllowAdjust != null">
  116. AND is_allow_adjust_ = #{isAllowAdjust,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  117. </if>
  118. <if test="subjectId != null">
  119. AND subject_id_ = #{subjectId}
  120. </if>
  121. </where>
  122. </sql>
  123. <!-- 分页查询 -->
  124. <select id="queryPage" resultMap="StudentRegistration" parameterType="map">
  125. SELECT * FROM student_registration ORDER BY id_
  126. <include refid="global.limit"/>
  127. </select>
  128. <!-- 查询当前表的总记录数 -->
  129. <select id="queryCount" resultType="int">
  130. SELECT COUNT(*)
  131. FROM student_registration
  132. </select>
  133. <sql id="queryStudentDetailPageSql">
  134. <where>
  135. <if test="musicGroupId != null">
  136. sr.music_group_id_ = #{musicGroupId}
  137. </if>
  138. <if test="subjectId != null">
  139. sr.subject_id_ = #{subjectId}
  140. </if>
  141. <if test="isAllowAdjust != null">
  142. sr.is_allow_adjust_ = #{isAllowAdjust}
  143. </if>
  144. <if test="actualSubjectId != null">
  145. sr.actual_subject_id_ = #{actualSubjectId}
  146. </if>
  147. </where>
  148. </sql>
  149. <resultMap type="com.ym.mec.biz.dal.dto.StudentApplyDetailDto" id="studentApplyDetail">
  150. <result column="current_grade_" property="currentGrade"/>
  151. <result column="current_class_" property="currentClass"/>
  152. <result column="is_allow_adjust_" property="isAllowAdjust"
  153. typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  154. <result column="parents_name_" property="parentsName"/>
  155. <result column="parents_phone_" property="parentsPhone"/>
  156. <result column="subject_name_" property="subjectName"/>
  157. <result column="username_" property="studentName"/>
  158. <result column="actual_subject_name_" property="actualSubjectName"/>
  159. <result column="gender_" property="gender" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  160. </resultMap>
  161. <select id="queryStudentDetailPage" resultMap="studentApplyDetail">
  162. SELECT su.username_,sr.parents_name_,sr.current_class_,sr.current_grade_,
  163. su.gender_,sr.is_allow_adjust_, s.name_ subject_name_,ss.name_ actual_subject_name_,sr.parents_phone_
  164. FROM student_registration sr
  165. LEFT JOIN sys_user su ON sr.subject_id_ = su.id_
  166. LEFT JOIN `subject` s ON sr.subject_id_ = s.id_
  167. LEFT JOIN `subject` ss ON sr.actual_subject_id_ = s.id_
  168. <include refid="queryStudentDetailPageSql"/>
  169. <include refid="global.limit"/>
  170. </select>
  171. <select id="queryStudentDetailCount" resultType="java.lang.Integer">
  172. SELECT COUNT(sr.id_) FROM student_registration sr
  173. <include refid="queryStudentDetailPageSql"/>
  174. </select>
  175. <select id="countPayNum" resultType="java.lang.Integer">
  176. SELECT COUNT(DISTINCT user_id_) FROM student_registration
  177. WHERE music_group_id_ = #{musicGroupId} AND subject_id_ = #{subjectId} AND payment_status_ = 1
  178. </select>
  179. <resultMap id="queryFeeDetailMap" type="com.ym.mec.biz.dal.dto.StudentFeeDto">
  180. <result column="deposit_fee_" property="depositFee"/>
  181. <result column="course_fee_" property="courseFee"/>
  182. <result column="musical_fee_" property="musicalFee"/>
  183. <result column="total_amount_" property="totalAmount"/>
  184. </resultMap>
  185. <select id="queryFeeDetail" resultMap="queryFeeDetailMap">
  186. </select>
  187. <!-- 根据乐团和声部获取未分班的学生 -->
  188. <select id="getNoClassStuBySubjectId" resultMap="StudentRegistration">
  189. SELECT * FROM student_registration WHERE music_group_id_ = #{musicGroupId} AND actual_subject_id_ =
  190. #{actualSubjectId} AND class_group_id_ >=1
  191. </select>
  192. <!-- 根据乐团和声部获取未分班人数 -->
  193. <select id="getNoClassStuCountBySubjectId" resultType="java.lang.Integer">
  194. SELECT count(*) FROM student_registration WHERE music_group_id_ = #{musicGroupId} AND actual_subject_id_ =
  195. #{actualSubjectId} AND class_group_id_ >=1
  196. </select>
  197. </mapper>