SysMusicCompareWeekDataMapper.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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.yonge.cooleshow.biz.dal.dao.SysMusicCompareWeekDataDao">
  8. <resultMap type="com.yonge.cooleshow.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.yonge.cooleshow.biz.dal.entity.SysMusicCompareWeekData">
  25. INSERT INTO sys_music_compare_week_data (user_id_,monday_,train_num_,train_days_,train_time_,
  26. beginner_max_score_,beginner_max_score_id_,advanced_max_score_,advanced_max_score_id_,
  27. performer_max_score_,performer_max_score_id_,
  28. create_time_,update_time_,tenant_id_)
  29. VALUES(#{userId},#{monday},#{trainNum},#{trainDays},#{trainTime},#{beginnerMaxScore},#{beginnerMaxScoreId},
  30. #{advancedMaxScore},#{advancedMaxScoreId},#{performerMaxScore},#{performerMaxScoreId},NOW(),NOW(),#{tenantId})
  31. </insert>
  32. <update id="update" parameterType="com.yonge.cooleshow.biz.dal.entity.SysMusicCompareWeekData">
  33. UPDATE sys_music_compare_week_data
  34. <set>
  35. <if test="trainNum!=null">
  36. train_num_ = #{trainNum},
  37. </if>
  38. <if test="trainDays!=null">
  39. train_days_ = #{trainDays},
  40. </if>
  41. <if test="trainTime!=null">
  42. train_time_ = #{trainTime},
  43. </if>
  44. <if test="beginnerMaxScore!=null">
  45. beginner_max_score_ = #{beginnerMaxScore},
  46. </if>
  47. <if test="beginnerMaxScoreId!=null">
  48. beginner_max_score_id_ = #{beginnerMaxScoreId},
  49. </if>
  50. <if test="advancedMaxScore!=null">
  51. advanced_max_score_ = #{advancedMaxScore},
  52. </if>
  53. <if test="advancedMaxScoreId!=null">
  54. advanced_max_score_id_ = #{advancedMaxScoreId},
  55. </if>
  56. <if test="performerMaxScore!=null">
  57. performer_max_score_ = #{performerMaxScore},
  58. </if>
  59. <if test="performerMaxScoreId!=null">
  60. performer_max_score_id_ = #{performerMaxScoreId},
  61. </if>
  62. update_time_ = NOW()
  63. </set>
  64. WHERE user_id_=#{userId} AND monday_ = #{monday} and tenant_id_ = #{tenantId}
  65. </update>
  66. <!-- 分页查询 -->
  67. <select id="queryPage" resultMap="SysMusicCompareWeekData" parameterType="map">
  68. SELECT * FROM sys_music_compare_week_data where tenant_id_ = #{tenantId} <include refid="global.limit"/>
  69. </select>
  70. <!-- 查询当前表的总记录数 -->
  71. <select id="queryCount" resultType="int">
  72. SELECT COUNT(*) FROM sys_music_compare_week_data where tenant_id_ = #{tenantId}
  73. </select>
  74. <select id="getWithUserAndMonday" resultMap="SysMusicCompareWeekData">
  75. SELECT * FROM sys_music_compare_week_data WHERE user_id_=#{userId} AND monday_=#{monday}
  76. </select>
  77. <select id="queryUserTrainStat" resultType="com.yonge.cooleshow.biz.dal.queryInfo.SysMusicCompareRecordQueryInfo$MusicCompareRankingDto">
  78. SELECT
  79. smcwd.user_id_ userId,
  80. su.avatar_ avatar,
  81. su.username_ studentName,
  82. <if test="orderType==1">
  83. sms.name_ musicScoreName,
  84. <if test="heardLevel==null">
  85. smcwd.advanced_max_score_ score,
  86. </if>
  87. <if test="heardLevel=='BEGINNER'">
  88. smcwd.beginner_max_score_ score,
  89. </if>
  90. <if test="heardLevel=='ADVANCED'">
  91. smcwd.advanced_max_score_ score,
  92. </if>
  93. <if test="heardLevel=='PERFORMER'">
  94. smcwd.performer_max_score_ score,
  95. </if>
  96. </if>
  97. smcwd.train_num_ trainNum,
  98. smcwd.train_days_ trainDays,
  99. smcwd.train_time_ trainTime,
  100. case when stu.membership_end_time_ &gt; now() then 1 else 0 end vipUser
  101. FROM sys_music_compare_week_data smcwd
  102. LEFT JOIN sys_user su ON smcwd.user_id_=su.id_
  103. LEFT JOIN student stu ON smcwd.user_id_ = stu.user_id_
  104. <if test="orderType==1">
  105. LEFT JOIN sys_music_score sms
  106. <if test="heardLevel==null">
  107. ON smcwd.advanced_max_score_id_ = sms.id_
  108. </if>
  109. <if test="heardLevel=='BEGINNER'">
  110. ON smcwd.beginner_max_score_id_ = sms.id_
  111. </if>
  112. <if test="heardLevel=='ADVANCED'">
  113. ON smcwd.advanced_max_score_id_ = sms.id_
  114. </if>
  115. <if test="heardLevel=='PERFORMER'">
  116. ON smcwd.performer_max_score_id_ = sms.id_
  117. </if>
  118. </if>
  119. WHERE smcwd.monday_ = #{monday}
  120. AND stu.user_id_ = smcwd.user_id_ and stu.tenant_id_ = #{tenantId}
  121. <if test="orderType==1">
  122. <if test="heardLevel==null">
  123. AND smcwd.advanced_max_score_ > 0
  124. </if>
  125. <if test="heardLevel=='BEGINNER'">
  126. AND smcwd.beginner_max_score_ > 0
  127. </if>
  128. <if test="heardLevel=='ADVANCED'">
  129. AND smcwd.advanced_max_score_ > 0
  130. </if>
  131. <if test="heardLevel=='PERFORMER'">
  132. AND smcwd.performer_max_score_ > 0
  133. </if>
  134. </if>
  135. ORDER BY
  136. <if test="orderType==null">
  137. smcwd.train_time_ DESC,
  138. </if>
  139. <if test="orderType==0">
  140. smcwd.train_time_ DESC,
  141. </if>
  142. <if test="orderType==1">
  143. <if test="heardLevel==null">
  144. smcwd.advanced_max_score_ DESC,
  145. </if>
  146. <if test="heardLevel=='BEGINNER'">
  147. smcwd.beginner_max_score_ DESC,
  148. </if>
  149. <if test="heardLevel=='ADVANCED'">
  150. smcwd.advanced_max_score_ DESC,
  151. </if>
  152. <if test="heardLevel=='PERFORMER'">
  153. smcwd.performer_max_score_ DESC,
  154. </if>
  155. </if>
  156. <if test="orderType==2">
  157. smcwd.train_days_ DESC,
  158. </if>
  159. smcwd.user_id_
  160. </select>
  161. </mapper>