package com.wzj.soopin.content.mapper;

import com.wzj.soopin.content.domain.po.MyLikedVlog;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;

@Repository
@Mapper
public interface MyLikedVlogMapper extends BaseMapperPlus<MyLikedVlog,MyLikedVlog> {
    /**
     * 统计某视频的点赞数
     */
    @Select("SELECT COUNT(*) FROM cont_my_liked_vlog WHERE vlog_id = #{vlogId}")
    int countLikesByVlogId(@Param("vlogId") String vlogId);

    @Select("SELECT m.nickname, m.avatar as face, l.create_time FROM cont_my_liked_vlog l LEFT JOIN ums_member m ON l.user_id = m.id WHERE l.vlog_id = #{vlogId} ORDER BY l.create_time DESC")
    List<Map<String, Object>> selectLikedUsersByVlogId(@Param("vlogId") String vlogId);
}
