package com.zhentao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhentao.entity.DynamicReport;
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 DynamicReportMapper extends BaseMapper<DynamicReport> {
    @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<Long> userIds);

    /**
     * 根据动态ID批量查询作者昵称（忽略软删除状态，因为需要显示被举报的动态作者信息）
     */
    @Select({
            "<script>",
            "SELECT d.dynamic_id, u.nickname, d.status, d.user_id ",
            "FROM user_dynamics d ",
            "LEFT JOIN users u ON d.user_id = u.user_id ",
            "WHERE d.dynamic_id IN",
            "<foreach collection='dynamicIds' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"
    })
    List<java.util.Map<String,Object>> findAuthorNickByDynamicIds(@Param("dynamicIds") List<Integer> dynamicIds);
}


