123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
- <mapper namespace="com.atguigu.tingshu.album.mapper.TrackInfoMapper">
- <select id="findUserTrackPage" resultType="com.atguigu.tingshu.vo.album.TrackListVo">
- select
- ti.id track_id,
- ti.track_title,
- ti.cover_url,
- ti.media_duration,
- ti.status,
- max(if(stat_type='0701', stat_num, 0)) playStatNum,
- max(if(stat_type='0702', stat_num, 0)) collectStatNum,
- max(if(stat_type='0703', stat_num, 0)) praiseStatNum,
- max(if(stat_type='0704', stat_num, 0)) commentStatNum
- from track_info ti inner join track_stat stat on stat.track_id = ti.id and stat.is_deleted = 0
- <where>
- <if test="vo.userId != null">
- and ti.user_id = #{vo.userId}
- </if>
- <if test="vo.status != null and vo.status != ''">
- and ti.status = #{vo.status}
- </if>
- <if test="vo.trackTitle != null and vo.trackTitle != ''">
- and ti.track_title like concat('%',#{vo.trackTitle},'%')
- </if>
- and ti.is_deleted = 0
- </where>
- group by ti.id
- order by ti.id desc
- </select>
-
- <select id="findAlbumTrackPage" resultType="com.atguigu.tingshu.vo.album.AlbumTrackListVo">
- select
- ti.id track_id,
- ti.track_title,
- ti.media_duration,
- ti.order_num,
- ti.create_time,
- max(if(stat_type='0701', stat_num, 0)) playStatNum,
- max(if(stat_type='0702', stat_num, 0)) collectStatNum,
- max(if(stat_type='0703', stat_num, 0)) praiseStatNum,
- max(if(stat_type='0704', stat_num, 0)) commentStatNum
- from track_info ti inner join track_stat ts on ts.track_id = ti.id and ts.is_deleted = 0
- where ti.album_id = #{albumId} and ti.status = '0501' and ti.is_deleted = 0
- group by ti.id
- order by ti.id asc
- </select>
- <select id="getTrackStatVo" resultType="com.atguigu.tingshu.vo.album.TrackStatVo">
- select
- track_id,
- max(if(stat_type='0701', stat_num, 0)) playStatNum,
- max(if(stat_type='0702', stat_num, 0)) collectStatNum,
- sum(if(stat_type='0703', stat_num, 0)) praiseStatNum,
- max(if(stat_type='0704', stat_num, 0)) commentStatNum
- from track_stat where track_id = #{trackId} and is_deleted = 0
- </select>
- </mapper>
|