實現完整的後台得獎資訊

This commit is contained in:
2025-09-27 02:42:22 +08:00
parent 2597a07514
commit b06fd94c99
8 changed files with 302 additions and 111 deletions

View File

@@ -9,10 +9,12 @@ import { CompetitionService } from '@/lib/services/database-service';
export async function GET(request: NextRequest, { params }: { params: { id: string } }) {
try {
const { id } = await params;
console.log('🔍 獲取競賽評審團 API 被調用競賽ID:', id);
// 獲取競賽信息
const competition = await CompetitionService.getCompetitionWithDetails(id);
if (!competition) {
console.log('❌ 競賽不存在:', id);
return NextResponse.json({
success: false,
message: '競賽不存在',
@@ -20,14 +22,22 @@ export async function GET(request: NextRequest, { params }: { params: { id: stri
}, { status: 404 });
}
console.log('✅ 找到競賽:', competition.name);
// 獲取競賽的評審團
const judges = await CompetitionService.getCompetitionJudges(id);
console.log('📊 查詢到評審數量:', judges.length);
console.log('👥 評審詳細資料:', judges);
return NextResponse.json({
const response = NextResponse.json({
success: true,
message: '競賽評審團獲取成功',
data: {
competition,
competition: {
id: competition.id,
name: competition.name,
type: competition.type
},
judges: judges.map(judge => ({
id: judge.id,
name: judge.name,
@@ -43,8 +53,15 @@ export async function GET(request: NextRequest, { params }: { params: { id: stri
}
});
// 設置快取控制標頭,防止快取
response.headers.set('Cache-Control', 'no-cache, no-store, must-revalidate');
response.headers.set('Pragma', 'no-cache');
response.headers.set('Expires', '0');
return response;
} catch (error) {
console.error('獲取競賽評審團失敗:', error);
console.error('獲取競賽評審團失敗:', error);
return NextResponse.json({
success: false,
message: '獲取競賽評審團失敗',