StudentRepairMapper.xml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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.StudentRepairDao">
  4. <resultMap id="StudentRepair" type="com.ym.mec.biz.dal.entity.StudentRepair">
  5. <result column="id_" jdbcType="INTEGER" property="id"/>
  6. <result column="trans_no_" jdbcType="VARCHAR" property="transNo"/>
  7. <result column="organ_id_" jdbcType="INTEGER" property="organId"/>
  8. <result column="name_" jdbcType="INTEGER" property="organName"/>
  9. <result column="student_id_" jdbcType="INTEGER" property="studentId"/>
  10. <result column="student_name_" jdbcType="VARCHAR" property="studentName"/>
  11. <result column="student_school_" jdbcType="VARCHAR" property="studentSchool"/>
  12. <result column="employee_id_" jdbcType="INTEGER" property="employeeId"/>
  13. <result column="employee_name_" jdbcType="VARCHAR" property="employeeName"/>
  14. <result column="subject_id_" jdbcType="INTEGER" property="subjectId"/>
  15. <result column="subject_name_" jdbcType="VARCHAR" property="subjectName"/>
  16. <result column="type_" jdbcType="INTEGER" property="type"/>
  17. <result column="instrument_no_" jdbcType="VARCHAR" property="instrumentNo"/>
  18. <result column="description_" jdbcType="VARCHAR" property="description"/>
  19. <result column="amount_" jdbcType="DECIMAL" property="amount"/>
  20. <result column="finish_time_" jdbcType="TIMESTAMP" property="finishTime"/>
  21. <result column="send_type_" jdbcType="INTEGER" property="sendType"/>
  22. <result column="contact_name_" jdbcType="VARCHAR" property="contactName"/>
  23. <result column="contact_mobile_" jdbcType="VARCHAR" property="contactMobile"/>
  24. <result column="address_" jdbcType="VARCHAR" property="address"/>
  25. <result column="pay_status_" jdbcType="INTEGER" property="payStatus"/>
  26. <result column="repair_status_" jdbcType="INTEGER" property="repairStatus"/>
  27. <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
  28. <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
  29. </resultMap>
  30. <!-- 根据主键查询一条记录 -->
  31. <select id="get" resultMap="StudentRepair">
  32. SELECT *
  33. FROM school
  34. WHERE id_ = #{id}
  35. </select>
  36. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentRepair" useGeneratedKeys="true" keyColumn="id"
  37. keyProperty="id">
  38. <!--@mbg.generated-->
  39. insert into student_repair (id_, trans_no_, organ_id_,
  40. student_id_, student_name_, student_school_,
  41. employee_id_, employee_name_, subject_id_,
  42. subject_name_, type_, instrument_no_,
  43. description_, amount_, finish_time_,
  44. send_type_, contact_name_, contact_mobile_,
  45. address_, pay_status_, create_time_,
  46. update_time_,repair_status_)
  47. values (#{id,jdbcType=INTEGER}, #{transNo,jdbcType=VARCHAR}, #{organId,jdbcType=INTEGER},
  48. #{studentId,jdbcType=INTEGER}, #{studentName,jdbcType=VARCHAR}, #{studentSchool,jdbcType=VARCHAR},
  49. #{employeeId,jdbcType=INTEGER}, #{employeeName,jdbcType=VARCHAR}, #{subjectId,jdbcType=INTEGER},
  50. #{subjectName,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{instrumentNo,jdbcType=VARCHAR},
  51. #{description,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, #{finishTime,jdbcType=TIMESTAMP},
  52. #{sendType,jdbcType=INTEGER}, #{contactName,jdbcType=VARCHAR}, #{contactMobile,jdbcType=VARCHAR},
  53. #{address,jdbcType=VARCHAR}, #{payStatus,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
  54. #{updateTime,jdbcType=TIMESTAMP},#{repairStatus})
  55. </insert>
  56. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentRepair">
  57. <!--@mbg.generated-->
  58. UPDATE student_repair
  59. <set>
  60. <if test="transNo != null">
  61. trans_no_ = #{transNo},
  62. </if>
  63. <if test="repairStatus != null">
  64. repair_status_ = #{repairStatus},
  65. </if>
  66. <if test="organId != null">
  67. organ_id_ = ##{organId},
  68. </if>
  69. <if test="studentId != null">
  70. student_id_ = #{studentId},
  71. </if>
  72. <if test="studentName != null">
  73. student_name_ = #{studentName},
  74. </if>
  75. <if test="studentSchool != null">
  76. student_school_ = #{studentSchool},
  77. </if>
  78. <if test="employeeId != null">
  79. employee_id_ = #{employeeId},
  80. </if>
  81. <if test="employeeName != null">
  82. employee_name_ = #{employeeName},
  83. </if>
  84. <if test="subjectId != null">
  85. subject_id_ = #{subjectId},
  86. </if>
  87. <if test="subjectName != null">
  88. subject_name_ = #{subjectName},
  89. </if>
  90. <if test="type != null">
  91. type_ = #{type},
  92. </if>
  93. <if test="instrumentNo != null">
  94. instrument_no_ = #{instrumentNo},
  95. </if>
  96. <if test="description != null">
  97. description_ = #{description},
  98. </if>
  99. <if test="amount != null">
  100. amount_ = #{amount},
  101. </if>
  102. <if test="finishTime != null">
  103. finish_time_ = #{finishTime},
  104. </if>
  105. <if test="sendType != null">
  106. send_type_ #{sendType},
  107. </if>
  108. <if test="contactName != null">
  109. contact_name_ = #{contactName},
  110. </if>
  111. <if test="contactMobile != null">
  112. contact_mobile_ = #{contactName},
  113. </if>
  114. <if test="address != null">
  115. address_ = #{address},
  116. </if>
  117. <if test="payStatus != null">
  118. pay_status_ = #{payStatus},
  119. </if>
  120. <if test="updateTime != null">
  121. update_time_ = #{updateTime},
  122. </if>
  123. </set>
  124. WHERE id_ = #{id}
  125. </update>
  126. <select id="getStudents" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  127. SELECT username_ ,id_ user_id_,avatar_ head_url_,gender_,phone_
  128. FROM sys_user
  129. WHERE FIND_IN_SET(organ_id_,#{organIdList})
  130. AND user_type_ LIKE '%STUDENT%'
  131. <if test="search">
  132. AND (username_ LIKE #{search}'%' OR phone_ LIKE #{search}'%')
  133. </if>
  134. AND id_ NOT IN (
  135. SELECT cssp.user_id_
  136. FROM music_group mg
  137. LEFT JOIN course_schedule_student_payment cssp ON mg.id_ = cssp.music_group_id_
  138. WHERE cssp.group_type_ = 'MUSIC'
  139. AND mg.repair_user_id_ != #{employeeId})
  140. <include refid="global.limit"/>
  141. </select>
  142. <select id="getStudentsCount" resultType="java.lang.Integer">
  143. SELECT COUNT(*) FROM sys_user
  144. WHERE FIND_IN_SET(organ_id_,#{organIdList})
  145. AND user_type_ LIKE '%STUDENT%'
  146. <if test="search">
  147. AND (username_ LIKE #{search}'%' OR phone_ LIKE #{search}'%')
  148. </if>
  149. AND id_ NOT IN (
  150. SELECT cssp.user_id_
  151. FROM music_group mg
  152. LEFT JOIN course_schedule_student_payment cssp ON mg.id_ = cssp.music_group_id_
  153. WHERE cssp.group_type_ = 'MUSIC'
  154. AND mg.repair_user_id_ != #{employeeId}
  155. )
  156. </select>
  157. <select id="queryPage" resultMap="StudentRepair">
  158. SELECT sr.*,o.name_ FROM student_repair sr
  159. LEFT JOIN organization o ON o.id_ = sr.organ_id_
  160. <include refid="queryPageSql"/>
  161. <include refid="global.limit"/>
  162. </select>
  163. <sql id="queryPageSql">
  164. <where>
  165. <if test="search != null and search != ''">
  166. AND (sr.trans_no_ LIKE CONCAT('%',#{search},'%') OR sr.student_id_ = #{search} OR sr.student_name_ LIKE
  167. CONCAT('%',#{search},'%'))
  168. </if>
  169. <if test="employeeId != null">
  170. AND sr.employee_id_ = #{employeeId}
  171. </if>
  172. <if test="studentId != null">
  173. AND sr.student_id_ = #{studentId}
  174. </if>
  175. <if test="organIdList != null and organIdList != ''">
  176. AND FIND_IN_SET(sr.organ_id_,#{organIdList})
  177. </if>
  178. <if test="subjectId != null">
  179. AND sr.subject_id_ = #{subjectId}
  180. </if>
  181. <if test="type != null">
  182. AND sr.type_ = #{type}
  183. </if>
  184. <if test="repairStatus != null">
  185. AND sr.repair_status_ = #{repairStatus}
  186. </if>
  187. <if test="startTime != null">
  188. AND sr.create_time_ >= #{startTime}
  189. </if>
  190. <if test="endTime != null">
  191. AND sr.create_time_ &lt;= #{endTime}
  192. </if>
  193. </where>
  194. </sql>
  195. <select id="queryCount" resultType="int">
  196. SELECT COUNT(id_) FROM student_repair sr
  197. <include refid="queryPageSql"/>
  198. </select>
  199. <select id="getUserMusicGroup" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.MusicGroup">
  200. SELECT mg.id_,mg.name_,sr.user_id_ repair_user_id_ FROM music_group mg
  201. LEFT JOIN student_registration sr on sr.music_group_id_ = mg.id_
  202. WHERE sr.user_id_ IN
  203. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  204. #{userId}
  205. </foreach>
  206. AND mg.status_='PROGRESS'
  207. ORDER BY id_ DESC
  208. </select>
  209. <select id="getStudentInfo" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  210. SELECT su.username_ ,su.id_ user_id_,su.avatar_ head_url_,su.gender_,mg.id_ music_group_id_,mg.name_ music_group_name_,sr.subject_id_ FROM sys_user su
  211. LEFT JOIN student_registration sr ON sr.user_id_ = su.id_
  212. LEFT JOIN music_group mg ON mg.id_ = sr.music_group_id_
  213. WHERE su.id_ = #{studentId}
  214. ORDER BY mg.id_ DESC LIMIT 1
  215. </select>
  216. </mapper>