StudentPreRegistrationMapper.xml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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.StudentPreRegistrationDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.StudentPreRegistration" id="StudentPreRegistration">
  9. <result column="id_" property="id"/>
  10. <result column="music_group_id_" property="musicGroupId"/>
  11. <result column="user_id_" property="userId"/>
  12. <result column="phone_" property="phone"/>
  13. <result column="user_name_" property="userName"/>
  14. <result column="gender_" property="gender"/>
  15. <result column="current_grade_" property="currentGrade"/>
  16. <result column="current_grade_num_" property="currentGradeNum"/>
  17. <result column="current_class_" property="currentClass"/>
  18. <result column="subject_first_" property="subjectFirst"/>
  19. <result column="subject_second_" property="subjectSecond"/>
  20. <result column="is_allow_adjust_" property="isAllowAdjust"/>
  21. <result column="kit_purchase_method_" property="kitPurchaseMethod"/>
  22. <result column="cloud_teacher_method_" property="cloudTeacherMethod"/>
  23. <result column="create_time_" property="createTime"/>
  24. <result column="is_registered_" property="isRegistered"/>
  25. </resultMap>
  26. <resultMap type="com.ym.mec.biz.dal.dto.StudentPreRegistrationDto" id="StudentPreRegistrationDto"
  27. extends="StudentPreRegistration">
  28. <result column="subject_first_name_" property="subjectFirstName"/>
  29. <result column="subject_second_name_" property="subjectSecondName"/>
  30. <result column="is_registered_" property="isRegistered"/>
  31. </resultMap>
  32. <resultMap type="com.ym.mec.common.entity.Mapper" id="Mapper">
  33. <result column="key_" property="key"/>
  34. <result column="value_" property="value"/>
  35. </resultMap>
  36. <!-- 根据主键查询一条记录 -->
  37. <select id="get" resultMap="StudentPreRegistration">
  38. SELECT *
  39. FROM student_pre_registration
  40. WHERE id_ = #{id}
  41. </select>
  42. <!-- 全查询 -->
  43. <select id="findAll" resultMap="StudentPreRegistration">
  44. SELECT *
  45. FROM student_pre_registration
  46. ORDER BY id_
  47. </select>
  48. <!-- 向数据库增加一条记录 -->
  49. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPreRegistration" useGeneratedKeys="true"
  50. keyColumn="id" keyProperty="id">
  51. <!--
  52. <selectKey resultClass="int" keyProperty="id" >
  53. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  54. </selectKey>
  55. -->
  56. INSERT INTO student_pre_registration
  57. (id_,music_group_id_,user_id_,phone_,user_name_,gender_,current_grade_,current_grade_num_,current_class_,subject_first_,subject_second_,is_allow_adjust_,kit_purchase_method_,cloud_teacher_method_,create_time_)
  58. VALUES(#{id},#{musicGroupId},#{userId},#{phone},#{userName},#{gender},#{currentGrade},#{currentGradeNum},#{currentClass},#{subjectFirst},#{subjectSecond},#{isAllowAdjust},#{kitPurchaseMethod},#{cloudTeacherMethod},#{createTime})
  59. </insert>
  60. <!-- 根据主键查询一条记录 -->
  61. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentPreRegistration">
  62. UPDATE student_pre_registration
  63. <set>
  64. <if test="musicGroupId != null">
  65. music_group_id_ = #{musicGroupId},
  66. </if>
  67. <if test="userId != null">
  68. user_id_ = #{userId},
  69. </if>
  70. <if test="userName != null">
  71. user_name_ = #{userName},
  72. </if>
  73. <if test="id != null">
  74. id_ = #{id},
  75. </if>
  76. <if test="currentGrade != null">
  77. current_grade_ = #{currentGrade},
  78. </if>
  79. <if test="currentGradeNum != null">
  80. current_grade_num_ = #{currentGradeNum},
  81. </if>
  82. <if test="gender != null">
  83. gender_ = #{gender},
  84. </if>
  85. <if test="subjectFirst != null">
  86. subject_first_ = #{subjectFirst},
  87. </if>
  88. <if test="phone != null">
  89. phone_ = #{phone},
  90. </if>
  91. <if test="subjectSecond != null">
  92. subject_second_ = #{subjectSecond},
  93. </if>
  94. <if test="currentClass != null">
  95. current_class_ = #{currentClass},
  96. </if>
  97. <if test="isAllowAdjust != null">
  98. is_allow_adjust_ = #{isAllowAdjust},
  99. </if>
  100. <if test="kitPurchaseMethod != null">
  101. kit_purchase_method_ = #{kitPurchaseMethod},
  102. </if>
  103. <if test="cloudTeacherMethod != null">
  104. cloud_teacher_method_ = #{cloudTeacherMethod},
  105. </if>
  106. <if test="createTime != null">
  107. create_time_ = #{createTime},
  108. </if>
  109. </set>
  110. WHERE id_ = #{id}
  111. </update>
  112. <!-- 根据主键删除一条记录 -->
  113. <delete id="delete">
  114. DELETE
  115. FROM student_pre_registration
  116. WHERE id_ = #{id}
  117. </delete>
  118. <!-- 分页查询 -->
  119. <select id="queryListForPage" resultMap="StudentPreRegistrationDto" parameterType="map">
  120. SELECT spr.*,case when sr.id_ is null then false else true end is_registered_,s1.name_
  121. subject_first_name_,s2.name_ subject_second_name_ FROM student_pre_registration spr
  122. left join subject s1 on s1.id_ = spr.subject_first_
  123. left join subject s2 on s2.id_ = spr.subject_second_
  124. left join student_registration sr on spr.music_group_id_ = sr.music_group_id_ and spr.user_id_ = sr.user_id_
  125. <where>
  126. <if test="musicGroupId != null">
  127. and spr.music_group_id_ = #{musicGroupId}
  128. </if>
  129. <if test="isAllowAdjust != null">
  130. and spr.is_allow_adjust_ = #{isAllowAdjust}
  131. </if>
  132. <if test="subjectId != null">
  133. and (spr.subject_first_ = #{subjectId} or spr.subject_second_ = #{subjectId})
  134. </if>
  135. <if test="name != null">
  136. and (spr.phone_ like concat('%',#{name},'%') or spr.user_name_ like concat('%',#{name},'%') or
  137. spr.user_id_ like concat('%',#{name},'%'))
  138. </if>
  139. <if test="isAllowAdjust != null">
  140. and spr.is_allow_adjust_ = #{isAllowAdjust}
  141. </if>
  142. </where>
  143. ORDER BY spr.id_
  144. <include refid="global.limit"/>
  145. </select>
  146. <!-- 查询当前表的总记录数 -->
  147. <select id="queryCount" resultType="int">
  148. SELECT COUNT(spr.id_) FROM student_pre_registration spr
  149. <where>
  150. <if test="musicGroupId != null">
  151. and spr.music_group_id_ = #{musicGroupId}
  152. </if>
  153. <if test="isAllowAdjust != null">
  154. and spr.is_allow_adjust_ = #{isAllowAdjust}
  155. </if>
  156. <if test="subjectId != null">
  157. and (spr.subject_first_ = #{subjectId} or spr.subject_second_ = #{subjectId})
  158. </if>
  159. <if test="name != null">
  160. and (spr.phone_ like concat('%',#{name},'%') or spr.user_name_ like concat('%',#{name},'%') or
  161. spr.user_id_ like concat('%',#{name},'%'))
  162. </if>
  163. <if test="isAllowAdjust != null">
  164. and spr.is_allow_adjust_ = #{isAllowAdjust}
  165. </if>
  166. </where>
  167. </select>
  168. <select id="queryFirstSubjectNum" resultMap="Mapper">
  169. SELECT ifnull(s.name_, '听从老师安排') key_, COUNT(spr.id_) value_
  170. FROM student_pre_registration spr
  171. left join subject s on s.id_ = spr.subject_first_
  172. where spr.music_group_id_ = #{musicGroupId}
  173. group by spr.subject_first_
  174. </select>
  175. <select id="querySecondSubjectNum" resultMap="Mapper">
  176. SELECT ifnull(s.name_, '听从老师安排') key_, COUNT(spr.id_) value_
  177. FROM student_pre_registration spr
  178. left join subject s on s.id_ = spr.subject_second_
  179. where spr.music_group_id_ = #{musicGroupId}
  180. group by spr.subject_second_
  181. </select>
  182. <select id="queryByMusicGroupIdAndUserId" resultMap="StudentPreRegistration" parameterType="map">
  183. SELECT *
  184. FROM student_pre_registration
  185. WHERE user_id_ = #{userId}
  186. and music_group_id_ = #{musicGroupId}
  187. </select>
  188. <select id="queryByMusicGroupIdAndPhone" resultMap="StudentPreRegistration" parameterType="map">
  189. SELECT *
  190. FROM student_pre_registration
  191. WHERE phone_ = #{phone}
  192. and music_group_id_ = #{musicGroupId}
  193. </select>
  194. <select id="queryByMusicGroupId" resultMap="StudentPreRegistration">
  195. SELECT *
  196. FROM student_pre_registration
  197. WHERE music_group_id_ = #{musicGroupId}
  198. </select>
  199. </mapper>