38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
// =====================================================
|
|
// 競賽參賽應用 API
|
|
// =====================================================
|
|
|
|
import { NextRequest, NextResponse } from 'next/server';
|
|
import { CompetitionService } from '@/lib/services/database-service';
|
|
|
|
// 獲取競賽的參賽應用
|
|
export async function GET(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
|
|
try {
|
|
const { id: competitionId } = await params;
|
|
|
|
if (!competitionId) {
|
|
return NextResponse.json({
|
|
success: false,
|
|
message: '缺少競賽ID參數'
|
|
}, { status: 400 });
|
|
}
|
|
|
|
// 獲取競賽的參賽應用
|
|
const apps = await CompetitionService.getCompetitionApps(competitionId);
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
message: '參賽應用獲取成功',
|
|
data: apps
|
|
});
|
|
|
|
} catch (error) {
|
|
console.error('獲取參賽應用失敗:', error);
|
|
return NextResponse.json({
|
|
success: false,
|
|
message: '獲取參賽應用失敗',
|
|
error: error instanceof Error ? error.message : '未知錯誤'
|
|
}, { status: 500 });
|
|
}
|
|
}
|