/**
 * ASL模块路由注册
 */

import { FastifyInstance } from 'fastify';
import * as projectController from '../controllers/projectController.js';
import * as literatureController from '../controllers/literatureController.js';
import * as screeningController from '../controllers/screeningController.js';

export async function aslRoutes(fastify: FastifyInstance) {
  // ==================== 筛选项目路由 ====================
  
  // 创建筛选项目
  fastify.post('/projects', projectController.createProject);
  
  // 获取用户的所有项目
  fastify.get('/projects', projectController.getProjects);
  
  // 获取单个项目详情
  fastify.get('/projects/:projectId', projectController.getProjectById);
  
  // 更新项目
  fastify.put('/projects/:projectId', projectController.updateProject);
  
  // 删除项目
  fastify.delete('/projects/:projectId', projectController.deleteProject);

  // ==================== 文献管理路由 ====================
  
  // 导入文献（JSON）
  fastify.post('/literatures/import', literatureController.importLiteratures);
  
  // 导入文献（Excel上传）
  fastify.post('/literatures/import-excel', literatureController.importLiteraturesFromExcel);
  
  // 获取项目的文献列表
  fastify.get('/projects/:projectId/literatures', literatureController.getLiteratures);
  
  // 删除文献
  fastify.delete('/literatures/:literatureId', literatureController.deleteLiterature);

  // ==================== 筛选任务路由 ====================
  
  // 获取筛选任务进度
  fastify.get('/projects/:projectId/screening-task', screeningController.getScreeningTask);
  
  // 获取筛选结果列表（分页）
  fastify.get('/projects/:projectId/screening-results', screeningController.getScreeningResults);
  
  // 获取单个筛选结果详情
  fastify.get('/screening-results/:resultId', screeningController.getScreeningResultDetail);
  
  // 提交人工复核
  fastify.post('/screening-results/:resultId/review', screeningController.reviewScreeningResult);
  
  // ⭐ 获取项目统计数据（Week 4 新增）
  fastify.get('/projects/:projectId/statistics', screeningController.getProjectStatistics);
  
  // TODO: 启动筛选任务（Week 2 Day 2 已实现为同步流程，异步版本待实现）
  // fastify.post('/projects/:projectId/screening/start', screeningController.startScreening);
}




