package com.zhentao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhentao.entity.Dynamic;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;

/**
 * 动态Mapper
 */
@Mapper
public interface DynamicMapper extends BaseMapper<Dynamic> {
    /**
     * 判断动态是否被举报
     */
    @Select("SELECT EXISTS(SELECT 1 FROM dynamic_reports dr WHERE dr.dynamic_id = #{dynamicId})")
    boolean existsReportByDynamicId(@Param("dynamicId") Integer dynamicId);

    /**
     * 批量查询用户昵称
     */
    @Select({
            "<script>",
            "SELECT user_id, nickname FROM users WHERE user_id IN",
            "<foreach collection='userIds' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"
    })
    List<java.util.Map<String, Object>> findNicknamesByUserIds(@Param("userIds") List<Integer> userIds);
}

