SysMusicCompareWeekDataMapper.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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.SysMusicCompareWeekDataDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.SysMusicCompareWeekData" id="SysMusicCompareWeekData">
  9. <result column="user_id_" property="userId" />
  10. <result column="monday_" property="monday" />
  11. <result column="train_num_" property="trainNum" />
  12. <result column="train_days_" property="trainDays" />
  13. <result column="train_time_" property="trainTime" />
  14. <result column="beginner_max_score_" property="beginnerMaxScore" />
  15. <result column="advanced_max_score_" property="advancedMaxScore" />
  16. <result column="performer_max_score_" property="performerMaxScore" />
  17. <result column="tenant_id_" property="tenantId"/>
  18. </resultMap>
  19. <!-- 全查询 -->
  20. <select id="findAll" resultMap="SysMusicCompareWeekData">
  21. SELECT * FROM sys_music_compare_week_data where tenant_id_ = #{tenantId}
  22. </select>
  23. <!-- 向数据库增加一条记录 -->
  24. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.SysMusicCompareWeekData">
  25. <!--
  26. <selectKey resultClass="int" keyProperty="id" >
  27. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  28. </selectKey>
  29. -->
  30. INSERT INTO sys_music_compare_week_data (user_id_,monday_,train_num_,train_days_,train_time_,
  31. beginner_max_score_,beginner_max_score_id_,advanced_max_score_,advanced_max_score_id_,
  32. performer_max_score_,performer_max_score_id_,
  33. create_time_,update_time_,tenant_id_)
  34. VALUES(#{userId},#{monday},#{trainNum},#{trainDays},#{trainTime},#{beginnerMaxScore},#{beginnerMaxScoreId},
  35. #{advancedMaxScore},#{advancedMaxScoreId},#{performerMaxScore},#{performerMaxScoreId},NOW(),NOW(),#{tenantId})
  36. </insert>
  37. <update id="update" parameterType="com.ym.mec.biz.dal.entity.SysMusicCompareWeekData">
  38. UPDATE sys_music_compare_week_data
  39. <set>
  40. <if test="trainNum!=null">
  41. train_num_ = #{trainNum},
  42. </if>
  43. <if test="trainDays!=null">
  44. train_days_ = #{trainDays},
  45. </if>
  46. <if test="trainTime!=null">
  47. train_time_ = #{trainTime},
  48. </if>
  49. <if test="beginnerMaxScore!=null">
  50. beginner_max_score_ = #{beginnerMaxScore},
  51. </if>
  52. <if test="beginnerMaxScoreId!=null">
  53. beginner_max_score_id_ = #{beginnerMaxScoreId},
  54. </if>
  55. <if test="advancedMaxScore!=null">
  56. advanced_max_score_ = #{advancedMaxScore},
  57. </if>
  58. <if test="advancedMaxScoreId!=null">
  59. advanced_max_score_id_ = #{advancedMaxScoreId},
  60. </if>
  61. <if test="performerMaxScore!=null">
  62. performer_max_score_ = #{performerMaxScore},
  63. </if>
  64. <if test="performerMaxScoreId!=null">
  65. performer_max_score_id_ = #{performerMaxScoreId},
  66. </if>
  67. update_time_ = NOW()
  68. </set>
  69. WHERE user_id_=#{userId} AND monday_ = #{monday} and tenant_id_ = #{tenantId}
  70. </update>
  71. <!-- 分页查询 -->
  72. <select id="queryPage" resultMap="SysMusicCompareWeekData" parameterType="map">
  73. SELECT * FROM sys_music_compare_week_data where tenant_id_ = #{tenantId} <include refid="global.limit"/>
  74. </select>
  75. <!-- 查询当前表的总记录数 -->
  76. <select id="queryCount" resultType="int">
  77. SELECT COUNT(*) FROM sys_music_compare_week_data where tenant_id_ = #{tenantId}
  78. </select>
  79. <select id="getWithUserAndMonday" resultMap="SysMusicCompareWeekData">
  80. SELECT * FROM sys_music_compare_week_data WHERE user_id_=#{userId} AND monday_=#{monday}
  81. </select>
  82. <select id="getUserTrainStat" resultType="com.ym.mec.biz.dal.dto.MusicCompareRankingDto">
  83. SELECT
  84. smcwd.user_id_ userId,
  85. su.avatar_ avatar,
  86. su.username_ studentName,
  87. <if test="orderType==1">
  88. sms.name_ musicScoreName,
  89. <if test="heardLevel==null">
  90. smcwd.advanced_max_score_ score,
  91. </if>
  92. <if test="heardLevel=='BEGINNER'">
  93. smcwd.beginner_max_score_ score,
  94. </if>
  95. <if test="heardLevel=='ADVANCED'">
  96. smcwd.advanced_max_score_ score,
  97. </if>
  98. <if test="heardLevel=='PERFORMER'">
  99. smcwd.performer_max_score_ score,
  100. </if>
  101. </if>
  102. smcwd.train_num_ trainNum,
  103. smcwd.train_days_ trainDays,
  104. smcwd.train_time_ trainTime
  105. FROM sys_music_compare_week_data smcwd
  106. LEFT JOIN sys_user su ON smcwd.user_id_=su.id_
  107. LEFT JOIN student stu ON smcwd.user_id_ = stu.user_id_
  108. <if test="orderType==1">
  109. LEFT JOIN sys_music_score sms
  110. <if test="heardLevel==null">
  111. ON smcwd.advanced_max_score_id_ = sms.id_
  112. </if>
  113. <if test="heardLevel=='BEGINNER'">
  114. ON smcwd.beginner_max_score_id_ = sms.id_
  115. </if>
  116. <if test="heardLevel=='ADVANCED'">
  117. ON smcwd.advanced_max_score_id_ = sms.id_
  118. </if>
  119. <if test="heardLevel=='PERFORMER'">
  120. ON smcwd.performer_max_score_id_ = sms.id_
  121. </if>
  122. </if>
  123. WHERE smcwd.monday_ = #{monday}
  124. AND stu.user_id_ = smcwd.user_id_ and smcwd.tenant_id_ = #{tenantId}
  125. <if test="organId != null">
  126. AND su.organ_id_ = #{organId}
  127. </if> <if test="orderType==1">
  128. <if test="heardLevel==null">
  129. AND smcwd.advanced_max_score_ > 0
  130. </if>
  131. <if test="heardLevel=='BEGINNER'">
  132. AND smcwd.beginner_max_score_ > 0
  133. </if>
  134. <if test="heardLevel=='ADVANCED'">
  135. AND smcwd.advanced_max_score_ > 0
  136. </if>
  137. <if test="heardLevel=='PERFORMER'">
  138. AND smcwd.performer_max_score_ > 0
  139. </if>
  140. </if>
  141. ORDER BY
  142. <if test="orderType==null">
  143. smcwd.train_time_ DESC,
  144. </if>
  145. <if test="orderType==0">
  146. smcwd.train_time_ DESC,
  147. </if>
  148. <if test="orderType==1">
  149. <if test="heardLevel==null">
  150. smcwd.advanced_max_score_ DESC,
  151. </if>
  152. <if test="heardLevel=='BEGINNER'">
  153. smcwd.beginner_max_score_ DESC,
  154. </if>
  155. <if test="heardLevel=='ADVANCED'">
  156. smcwd.advanced_max_score_ DESC,
  157. </if>
  158. <if test="heardLevel=='PERFORMER'">
  159. smcwd.performer_max_score_ DESC,
  160. </if>
  161. </if>
  162. <if test="orderType==2">
  163. smcwd.train_days_ DESC,
  164. </if>
  165. smcwd.user_id_
  166. </select>
  167. </mapper>