import { NextResponse } from 'next/server';
import { CriteriaTemplateService } from '@/lib/services/database';

// GET - 獲取預設評分標準模板
export async function GET() {
  try {
    const template = await CriteriaTemplateService.findDefault();
    
    if (!template) {
      return NextResponse.json(
        { success: false, error: '找不到預設評分標準模板' },
        { status: 404 }
      );
    }

    const templateWithItems = await CriteriaTemplateService.findWithItems(template.id);

    return NextResponse.json({
      success: true,
      data: templateWithItems
    });
  } catch (error) {
    console.error('獲取預設評分標準模板失敗:', error);
    return NextResponse.json(
      { success: false, error: '獲取預設評分標準模板失敗' },
      { status: 500 }
    );
  }
}
