<?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.yonge.cooleshow.biz.dal.mapper.UserMusicStarMapper">



    <!-- 表字段 -->
    <sql id="baseColumns">
         t.id_ AS id
        , t.user_id_ AS userId
        , t.client_type_ AS clientType
        , t.user_music_id_ AS userMusicId
        , t.create_time_ AS createTime
        </sql>

    <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.entity.UserMusicStar">
		SELECT
        	<include refid="baseColumns" />
		FROM user_music_star t
        <where>
            <if test="param.userMusicId != null">
                AND t.user_music_id_ = #{param.userMusicId}
            </if>
        </where>
        order by t.create_time_ desc ,t.id_ desc
	</select>

    <select id="getStarCountMapByUserMusicIds"
            resultType="com.yonge.cooleshow.biz.dal.wrapper.UserMusicStarWrapper$StarCount">
        SELECT
            t.user_music_id_ AS userMusicId,
            count(1) AS starCount
        FROM user_music_star t
        WHERE t.user_music_id_ IN
        <foreach collection="userMusicIds" item="userMusicId" separator="," open="(" close=")">
            #{userMusicId}
        </foreach>
        GROUP BY t.user_music_id_


    </select>
</mapper>
