package com.zhentao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhentao.entity.Blacklist;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BlacklistMapper extends BaseMapper<Blacklist> {
    
    @Select("SELECT * FROM blacklist WHERE user_id = #{userId} ORDER BY created_at DESC")
    List<Blacklist> selectByUserId(@Param("userId") Long userId);
    
    @Select("SELECT * FROM blacklist WHERE user_id = #{userId} AND blocked_user_id = #{blockedUserId} LIMIT 1")
    Blacklist selectByUserAndBlocked(@Param("userId") Long userId, @Param("blockedUserId") Long blockedUserId);
    
    @Select("SELECT blocked_user_id FROM blacklist WHERE user_id = #{userId}")
    List<Long> selectBlockedUserIds(@Param("userId") Long userId);
}


