StudentPreRegistrationMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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="teacher_recommand_subject_id_" property="teacherRecommandSubjectId"/>
  21. <result column="selection_subject_id_" property="selectionSubjectId"/>
  22. <result column="is_allow_adjust_" property="isAllowAdjust"/>
  23. <result column="kit_purchase_method_" property="kitPurchaseMethod"/>
  24. <result column="cloud_teacher_method_" property="cloudTeacherMethod"/>
  25. <result column="create_time_" property="createTime"/>
  26. <result column="is_registered_" property="isRegistered"/>
  27. <result column="tenant_id_" property="tenantId"/>
  28. </resultMap>
  29. <resultMap type="com.ym.mec.biz.dal.dto.StudentPreRegistrationDto" id="StudentPreRegistrationDto"
  30. extends="StudentPreRegistration">
  31. <result column="subject_first_name_" property="subjectFirstName"/>
  32. <result column="subject_second_name_" property="subjectSecondName"/>
  33. <result column="teacher_recommand_subject_name_" property="teacherRecommandSubjectName"/>
  34. <result column="selection_subject_name_" property="selectionSubjectName"/>
  35. <result column="is_registered_" property="isRegistered"/>
  36. </resultMap>
  37. <resultMap type="com.ym.mec.common.entity.Mapper" id="Mapper">
  38. <result column="key_" property="key"/>
  39. <result column="value_" property="value"/>
  40. </resultMap>
  41. <!-- 根据主键查询一条记录 -->
  42. <select id="get" resultMap="StudentPreRegistration">
  43. SELECT *
  44. FROM student_pre_registration
  45. WHERE id_ = #{id}
  46. </select>
  47. <!-- 全查询 -->
  48. <select id="findAll" resultMap="StudentPreRegistration">
  49. SELECT spr.*
  50. FROM student_pre_registration spr
  51. <where>
  52. spr.tenant_id_ = #{tenantId}
  53. <if test="musicGroupId != null">
  54. and spr.music_group_id_ = #{musicGroupId}
  55. </if>
  56. <if test="isAllowAdjust != null">
  57. and spr.is_allow_adjust_ = #{isAllowAdjust}
  58. </if>
  59. <if test="subjectId != null">
  60. and (spr.subject_first_ = #{subjectId} or spr.subject_second_ = #{subjectId})
  61. </if>
  62. <if test="name != null">
  63. and (spr.phone_ like concat('%',#{name},'%') or spr.user_name_ like concat('%',#{name},'%') or
  64. spr.user_id_ like concat('%',#{name},'%'))
  65. </if>
  66. <if test="isAllowAdjust != null">
  67. and spr.is_allow_adjust_ = #{isAllowAdjust}
  68. </if>
  69. <if test="kitPurchaseMethod != null">
  70. and spr.kit_purchase_method_ = #{kitPurchaseMethod}
  71. </if>
  72. <if test="cloudTeacherMethod != null">
  73. and spr.cloud_teacher_method_ = #{cloudTeacherMethod}
  74. </if>
  75. </where>
  76. ORDER BY spr.id_
  77. </select>
  78. <!-- 向数据库增加一条记录 -->
  79. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPreRegistration" useGeneratedKeys="true"
  80. keyColumn="id" keyProperty="id">
  81. INSERT INTO student_pre_registration
  82. (music_group_id_,user_id_,phone_,user_name_,gender_,current_grade_,current_grade_num_,
  83. current_class_,subject_first_,subject_second_,teacher_recommand_subject_id_,selection_subject_id_,
  84. is_allow_adjust_,kit_purchase_method_,cloud_teacher_method_,create_time_,tenant_id_)
  85. VALUES(#{musicGroupId},#{userId},#{phone},#{userName},#{gender},#{currentGrade},#{currentGradeNum},
  86. #{currentClass},#{subjectFirst},#{subjectSecond},#{teacherRecommandSubjectId},#{selectionSubjectId},
  87. #{isAllowAdjust},#{kitPurchaseMethod},#{cloudTeacherMethod},NOW(),#{tenantId})
  88. </insert>
  89. <!-- 根据主键查询一条记录 -->
  90. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentPreRegistration">
  91. UPDATE student_pre_registration
  92. <set>
  93. <if test="musicGroupId != null">
  94. music_group_id_ = #{musicGroupId},
  95. </if>
  96. <if test="userId != null">
  97. user_id_ = #{userId},
  98. </if>
  99. <if test="userName != null">
  100. user_name_ = #{userName},
  101. </if>
  102. <if test="currentGrade != null">
  103. current_grade_ = #{currentGrade},
  104. </if>
  105. <if test="currentGradeNum != null">
  106. current_grade_num_ = #{currentGradeNum},
  107. </if>
  108. <if test="gender != null">
  109. gender_ = #{gender},
  110. </if>
  111. <if test="subjectFirst != null">
  112. subject_first_ = #{subjectFirst},
  113. </if>
  114. <if test="phone != null">
  115. phone_ = #{phone},
  116. </if>
  117. <if test="subjectSecond != null">
  118. subject_second_ = #{subjectSecond},
  119. </if>
  120. <if test="teacherRecommandSubjectId != null">
  121. teacher_recommand_subject_id_ = #{teacherRecommandSubjectId},
  122. </if>
  123. <if test="selectionSubjectId != null">
  124. selection_subject_id_ = #{selectionSubjectId},
  125. </if>
  126. <if test="currentClass != null">
  127. current_class_ = #{currentClass},
  128. </if>
  129. <if test="isAllowAdjust != null">
  130. is_allow_adjust_ = #{isAllowAdjust},
  131. </if>
  132. <if test="kitPurchaseMethod != null">
  133. kit_purchase_method_ = #{kitPurchaseMethod},
  134. </if>
  135. <if test="cloudTeacherMethod != null">
  136. cloud_teacher_method_ = #{cloudTeacherMethod},
  137. </if>
  138. </set>
  139. WHERE id_ = #{id} and tenant_id_ = #{tenantId}
  140. </update>
  141. <!-- 根据主键删除一条记录 -->
  142. <delete id="delete">
  143. DELETE
  144. FROM student_pre_registration
  145. WHERE id_ = #{id}
  146. </delete>
  147. <!-- 分页查询 -->
  148. <select id="queryListForPage" resultMap="StudentPreRegistrationDto" parameterType="map">
  149. SELECT spr.*,case when sr.id_ is null then false else true end is_registered_,s1.name_
  150. subject_first_name_,s2.name_ subject_second_name_,s3.name_ teacher_recommand_subject_name_,s4.name_ selection_subject_name_ FROM student_pre_registration spr
  151. left join subject s1 on s1.id_ = spr.subject_first_
  152. left join subject s2 on s2.id_ = spr.subject_second_
  153. left join subject s3 on s3.id_ = spr.teacher_recommand_subject_id_
  154. left join subject s4 on s4.id_ = spr.selection_subject_id_
  155. left join student_registration sr on spr.music_group_id_ = sr.music_group_id_ and spr.user_id_ = sr.user_id_
  156. <where>
  157. spr.tenant_id_ = #{tenantId}
  158. <if test="musicGroupId != null">
  159. and spr.music_group_id_ = #{musicGroupId}
  160. </if>
  161. <if test="isAllowAdjust != null">
  162. and spr.is_allow_adjust_ = #{isAllowAdjust}
  163. </if>
  164. <if test="subjectId != null">
  165. and (spr.subject_first_ = #{subjectId} or spr.subject_second_ = #{subjectId})
  166. </if>
  167. <if test="teacherRecommandSubjectId != null">
  168. and (spr.teacher_recommand_subject_id_ = #{teacherRecommandSubjectId})
  169. </if>
  170. <if test="selectionSubjectId != null">
  171. and (spr.selection_subject_id_ = #{selectionSubjectId})
  172. </if>
  173. <if test="name != null">
  174. and (spr.phone_ like concat('%',#{name},'%') or spr.user_name_ like concat('%',#{name},'%') or
  175. spr.user_id_ like concat('%',#{name},'%'))
  176. </if>
  177. <if test="isAllowAdjust != null">
  178. and spr.is_allow_adjust_ = #{isAllowAdjust}
  179. </if>
  180. <if test="kitPurchaseMethod != null">
  181. and spr.kit_purchase_method_ = #{kitPurchaseMethod}
  182. </if>
  183. <if test="cloudTeacherMethod != null">
  184. and spr.cloud_teacher_method_ = #{cloudTeacherMethod}
  185. </if>
  186. </where>
  187. ORDER BY spr.id_
  188. <include refid="global.limit"/>
  189. </select>
  190. <!-- 查询当前表的总记录数 -->
  191. <select id="queryCount" resultType="int">
  192. SELECT COUNT(spr.id_) FROM student_pre_registration spr
  193. <where>
  194. spr.tenant_id_ = #{tenantId}
  195. <if test="musicGroupId != null">
  196. and spr.music_group_id_ = #{musicGroupId}
  197. </if>
  198. <if test="isAllowAdjust != null">
  199. and spr.is_allow_adjust_ = #{isAllowAdjust}
  200. </if>
  201. <if test="subjectId != null">
  202. and (spr.subject_first_ = #{subjectId} or spr.subject_second_ = #{subjectId})
  203. </if>
  204. <if test="teacherRecommandSubjectId != null">
  205. and (spr.teacher_recommand_subject_id_ = #{teacherRecommandSubjectId})
  206. </if>
  207. <if test="selectionSubjectId != null">
  208. and (spr.selection_subject_id_ = #{selectionSubjectId})
  209. </if>
  210. <if test="name != null">
  211. and (spr.phone_ like concat('%',#{name},'%') or spr.user_name_ like concat('%',#{name},'%') or
  212. spr.user_id_ like concat('%',#{name},'%'))
  213. </if>
  214. <if test="isAllowAdjust != null">
  215. and spr.is_allow_adjust_ = #{isAllowAdjust}
  216. </if>
  217. <if test="kitPurchaseMethod != null">
  218. and spr.kit_purchase_method_ = #{kitPurchaseMethod}
  219. </if>
  220. <if test="cloudTeacherMethod != null">
  221. and spr.cloud_teacher_method_ = #{cloudTeacherMethod}
  222. </if>
  223. </where>
  224. </select>
  225. <select id="queryFirstSubjectNum" resultMap="Mapper">
  226. SELECT case when spr.subject_first_ = 999 then '听从老师安排' else ifnull(s.name_,'无') end key_, COUNT(spr.id_) value_
  227. FROM student_pre_registration spr
  228. left join subject s on s.id_ = spr.subject_first_
  229. where spr.music_group_id_ = #{musicGroupId}
  230. group by spr.subject_first_
  231. </select>
  232. <select id="querySecondSubjectNum" resultMap="Mapper">
  233. SELECT case when spr.subject_second_ = 999 then '听从老师安排' else ifnull(s.name_,'无') end key_, COUNT(spr.id_) value_
  234. FROM student_pre_registration spr
  235. left join subject s on s.id_ = spr.subject_second_
  236. where spr.music_group_id_ = #{musicGroupId}
  237. group by spr.subject_second_
  238. </select>
  239. <select id="queryTeacherRecommandSubjectNum" resultMap="Mapper">
  240. SELECT case when spr.teacher_recommand_subject_id_ = 999 then '听从老师安排' else ifnull(s.name_,'无') end key_, COUNT(spr.id_) value_
  241. FROM student_pre_registration spr
  242. left join subject s on s.id_ = spr.teacher_recommand_subject_id_
  243. where spr.music_group_id_ = #{musicGroupId}
  244. group by spr.teacher_recommand_subject_id_
  245. </select>
  246. <select id="querySelectionSubjectNum" resultMap="Mapper">
  247. SELECT case when spr.selection_subject_id_ = 999 then '听从老师安排' else ifnull(s.name_,'无') end key_, COUNT(spr.id_) value_
  248. FROM student_pre_registration spr
  249. left join subject s on s.id_ = spr.selection_subject_id_
  250. where spr.music_group_id_ = #{musicGroupId}
  251. group by spr.selection_subject_id_
  252. </select>
  253. <select id="queryByMusicGroupIdAndUserId" resultMap="StudentPreRegistration" parameterType="map">
  254. SELECT *
  255. FROM student_pre_registration
  256. WHERE user_id_ = #{userId}
  257. and music_group_id_ = #{musicGroupId}
  258. </select>
  259. <select id="queryByMusicGroupIdAndPhone" resultMap="StudentPreRegistration" parameterType="map">
  260. SELECT *
  261. FROM student_pre_registration
  262. WHERE phone_ = #{phone}
  263. and music_group_id_ = #{musicGroupId}
  264. </select>
  265. <select id="queryByMusicGroupId" resultMap="StudentPreRegistration">
  266. SELECT *
  267. FROM student_pre_registration
  268. WHERE music_group_id_ = #{musicGroupId}
  269. </select>
  270. <select id="getPreRegisterNum" resultType="com.ym.mec.biz.dal.dto.MusicGroupRegAndMoneyDto">
  271. SELECT music_group_id_ musicGroupId, COUNT(*) preRegNum FROM student_pre_registration WHERE music_group_id_ IN
  272. <foreach collection="musicGroupIds" item="musicGroupId" open="(" close=")" separator=",">
  273. #{musicGroupId}
  274. </foreach>
  275. GROUP BY music_group_id_
  276. </select>
  277. </mapper>