import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
import { conversationController } from '../controllers/conversationController.js';

export async function conversationRoutes(fastify: FastifyInstance) {
  // 创建对话
  fastify.post('/conversations', async (request: FastifyRequest, reply: FastifyReply) => {
    return conversationController.createConversation(request as any, reply);
  });

  // 获取对话列表
  fastify.get('/conversations', async (request: FastifyRequest, reply: FastifyReply) => {
    return conversationController.getConversations(request as any, reply);
  });

  // 获取对话详情
  fastify.get('/conversations/:id', async (request: FastifyRequest, reply: FastifyReply) => {
    return conversationController.getConversationById(request as any, reply);
  });

  // 发送消息（非流式）
  fastify.post('/conversations/message', async (request: FastifyRequest, reply: FastifyReply) => {
    return conversationController.sendMessage(request as any, reply);
  });

  // 发送消息（流式输出）
  fastify.post('/conversations/message/stream', async (request: FastifyRequest, reply: FastifyReply) => {
    return conversationController.sendMessageStream(request as any, reply);
  });

  // 删除对话
  fastify.delete('/conversations/:id', async (request: FastifyRequest, reply: FastifyReply) => {
    return conversationController.deleteConversation(request as any, reply);
  });
}

