package com.m2pool.chat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.m2pool.chat.dto.ChatMessageDto;
import com.m2pool.chat.entity.ChatMessage;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

@Mapper
public interface ChatMessageMapper extends BaseMapper<ChatMessage> {

    /**
     * 根据游标查询十条数据
     * @param id
     * @param pageNum
     * @param roomId
     * @return
     */
    List<ChatMessageDto> findRecentlyMessage(@Param("email")String email,@Param("id") Long id,@Param("pageNum") Integer pageNum,@Param("roomId") Long roomId);


    /**
     * 查询未读消息条数
     * @param userEmails
     * @return Map<String, Integer>，键为用户邮箱，值为未读消息条数
     */
    @MapKey("userEmail")
    Map<String, Map<String,Integer>> findUnReadNums(@Param("userEmails") List<String> userEmails);


    /**
     * 查询当前客服参与过的所有聊天室
     * @param userEmail
     * @return
     */
    List<Long> findRoomIdsByCustomerEmail(@Param("userEmail") String userEmail);
}
