TrackInfoMapper.xml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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.atguigu.tingshu.album.mapper.TrackInfoMapper">
  4. <select id="findUserTrackPage" resultType="com.atguigu.tingshu.vo.album.TrackListVo">
  5. select
  6. ti.id track_id,
  7. ti.track_title,
  8. ti.cover_url,
  9. ti.media_duration,
  10. ti.status,
  11. max(if(stat_type='0701', stat_num, 0)) playStatNum,
  12. max(if(stat_type='0702', stat_num, 0)) collectStatNum,
  13. max(if(stat_type='0703', stat_num, 0)) praiseStatNum,
  14. max(if(stat_type='0704', stat_num, 0)) commentStatNum
  15. from track_info ti inner join track_stat stat on stat.track_id = ti.id and stat.is_deleted = 0
  16. <where>
  17. <if test="vo.userId != null">
  18. and ti.user_id = #{vo.userId}
  19. </if>
  20. <if test="vo.status != null and vo.status != ''">
  21. and ti.status = #{vo.status}
  22. </if>
  23. <if test="vo.trackTitle != null and vo.trackTitle != ''">
  24. and ti.track_title like concat('%',#{vo.trackTitle},'%')
  25. </if>
  26. and ti.is_deleted = 0
  27. </where>
  28. group by ti.id
  29. order by ti.id desc
  30. </select>
  31. <!--分页获取专辑下声音列表-->
  32. <select id="findAlbumTrackPage" resultType="com.atguigu.tingshu.vo.album.AlbumTrackListVo">
  33. select
  34. ti.id track_id,
  35. ti.track_title,
  36. ti.media_duration,
  37. ti.order_num,
  38. ti.create_time,
  39. max(if(stat_type='0701', stat_num, 0)) playStatNum,
  40. max(if(stat_type='0702', stat_num, 0)) collectStatNum,
  41. max(if(stat_type='0703', stat_num, 0)) praiseStatNum,
  42. max(if(stat_type='0704', stat_num, 0)) commentStatNum
  43. from track_info ti inner join track_stat ts on ts.track_id = ti.id and ts.is_deleted = 0
  44. where ti.album_id = #{albumId} and ti.status = '0501' and ti.is_deleted = 0
  45. group by ti.id
  46. order by ti.id asc
  47. </select>
  48. <select id="getTrackStatVo" resultType="com.atguigu.tingshu.vo.album.TrackStatVo">
  49. select
  50. track_id,
  51. max(if(stat_type='0701', stat_num, 0)) playStatNum,
  52. max(if(stat_type='0702', stat_num, 0)) collectStatNum,
  53. sum(if(stat_type='0703', stat_num, 0)) praiseStatNum,
  54. max(if(stat_type='0704', stat_num, 0)) commentStatNum
  55. from track_stat where track_id = #{trackId} and is_deleted = 0
  56. </select>
  57. </mapper>