package top.tqx.demo_1.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import top.tqx.demo_1.entity.ChatMessage;

@Mapper
public interface ChatMessageMapper extends BaseMapper<ChatMessage> {
    
    @Select("SELECT * FROM context_message WHERE conversation_id = #{sessionId} AND role = 'assistant' AND content = #{content} ORDER BY create_time DESC LIMIT 1")
    ChatMessage findAssistantMessageByContent(@Param("sessionId") Long sessionId, @Param("content") String content);
}