StudentPreRegistrationMapper.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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="create_time_" property="createTime" />
  23. <result column="is_registered_" property="isRegistered" />
  24. </resultMap>
  25. <resultMap type="com.ym.mec.biz.dal.dto.StudentPreRegistrationDto" id="StudentPreRegistrationDto" extends="StudentPreRegistration">
  26. <result column="subject_first_name_" property="subjectFirstName" />
  27. <result column="subject_second_name_" property="subjectSecondName" />
  28. <result column="is_registered_" property="isRegistered" />
  29. </resultMap>
  30. <!-- 根据主键查询一条记录 -->
  31. <select id="get" resultMap="StudentPreRegistration" >
  32. SELECT * FROM student_pre_registration WHERE id_ = #{id}
  33. </select>
  34. <!-- 全查询 -->
  35. <select id="findAll" resultMap="StudentPreRegistration">
  36. SELECT * FROM student_pre_registration ORDER BY id_
  37. </select>
  38. <!-- 向数据库增加一条记录 -->
  39. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPreRegistration" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  40. <!--
  41. <selectKey resultClass="int" keyProperty="id" >
  42. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  43. </selectKey>
  44. -->
  45. INSERT INTO student_pre_registration (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_,create_time_) VALUES(#{id},#{musicGroupId},#{userId},#{phone},#{userName},#{gender},#{currentGrade},#{currentGradeNum},#{currentClass},#{subjectFirst},#{subjectSecond},#{isAllowAdjust},#{kitPurchaseMethod},#{createTime})
  46. </insert>
  47. <!-- 根据主键查询一条记录 -->
  48. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentPreRegistration">
  49. UPDATE student_pre_registration <set>
  50. <if test="musicGroupId != null">
  51. music_group_id_ = #{musicGroupId},
  52. </if>
  53. <if test="userId != null">
  54. user_id_ = #{userId},
  55. </if>
  56. <if test="userName != null">
  57. user_name_ = #{userName},
  58. </if>
  59. <if test="id != null">
  60. id_ = #{id},
  61. </if>
  62. <if test="currentGrade != null">
  63. current_grade_ = #{currentGrade},
  64. </if>
  65. <if test="currentGradeNum != null">
  66. current_grade_num_ = #{currentGradeNum},
  67. </if>
  68. <if test="gender != null">
  69. gender_ = #{gender},
  70. </if>
  71. <if test="subjectFirst != null">
  72. subject_first_ = #{subjectFirst},
  73. </if>
  74. <if test="phone != null">
  75. phone_ = #{phone},
  76. </if>
  77. <if test="subjectSecond != null">
  78. subject_second_ = #{subjectSecond},
  79. </if>
  80. <if test="currentClass != null">
  81. current_class_ = #{currentClass},
  82. </if>
  83. <if test="isAllowAdjust != null">
  84. is_allow_adjust_ = #{isAllowAdjust},
  85. </if>
  86. <if test="kitPurchaseMethod != null">
  87. kit_purchase_method_ = #{kitPurchaseMethod},
  88. </if>
  89. <if test="createTime != null">
  90. create_time_ = #{createTime},
  91. </if>
  92. </set> WHERE id_ = #{id}
  93. </update>
  94. <!-- 根据主键删除一条记录 -->
  95. <delete id="delete" >
  96. DELETE FROM student_pre_registration WHERE id_ = #{id}
  97. </delete>
  98. <!-- 分页查询 -->
  99. <select id="queryListForPage" resultMap="StudentPreRegistrationDto" parameterType="map">
  100. SELECT spr.*,case when sr.id_ is null then false else true end is_registered_,s1.name_ subject_first_name_,s2.name_ subject_second_name_ FROM student_pre_registration spr
  101. left join subject s1 on s1.id_ = spr.subject_first_
  102. left join subject s2 on s2.id_ = spr.subject_second_
  103. left join student_registration sr on spr.music_group_id_ = sr.music_group_id_ and spr.user_id_ = sr.user_id_
  104. <where>
  105. <if test="musicGroupId != null">
  106. and spr.music_group_id_ = #{musicGroupId}
  107. </if>
  108. <if test="isAllowAdjust != null">
  109. and spr.is_allow_adjust_ = #{isAllowAdjust}
  110. </if>
  111. <if test="subjectId != null">
  112. and (spr.subject_first_ = #{subjectId} or spr.subject_second_ = #{subjectId})
  113. </if>
  114. <if test="name != null">
  115. and (spr.phone_ like concat('%',#{name},'%') or spr.user_name_ like concat('%',#{name},'%') or spr.user_id_ like concat('%',#{name},'%'))
  116. </if>
  117. <if test="isAllowAdjust != null">
  118. and spr.is_allow_adjust_ = #{isAllowAdjust}
  119. </if>
  120. </where>
  121. ORDER BY spr.id_ <include refid="global.limit"/>
  122. </select>
  123. <!-- 查询当前表的总记录数 -->
  124. <select id="queryCount" resultType="int">
  125. SELECT COUNT(spr.id_) FROM student_pre_registration spr
  126. <where>
  127. <if test="musicGroupId != null">
  128. and spr.music_group_id_ = #{musicGroupId}
  129. </if>
  130. <if test="isAllowAdjust != null">
  131. and spr.is_allow_adjust_ = #{isAllowAdjust}
  132. </if>
  133. <if test="subjectId != null">
  134. and (spr.subject_first_ = #{subjectId} or spr.subject_second_ = #{subjectId})
  135. </if>
  136. <if test="name != null">
  137. and (spr.phone_ like concat('%',#{name},'%') or spr.user_name_ like concat('%',#{name},'%') or 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. </select>
  144. <select id="queryByMusicGroupIdAndUserId" resultMap="StudentPreRegistration" parameterType="map">
  145. SELECT * FROM student_pre_registration WHERE user_id_ = #{userId} and music_group_id_ = #{musicGroupId}
  146. </select>
  147. <select id="queryByMusicGroupIdAndPhone" resultMap="StudentPreRegistration" parameterType="map">
  148. SELECT * FROM student_pre_registration WHERE phone_ = #{phone} and music_group_id_ = #{musicGroupId}
  149. </select>
  150. <select id="queryByMusicGroupId" resultMap="StudentPreRegistration">
  151. SELECT * FROM student_pre_registration WHERE music_group_id_ = #{musicGroupId}
  152. </select>
  153. </mapper>