55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
// =====================================================
|
|
// 競賽評審團 API
|
|
// =====================================================
|
|
|
|
import { NextRequest, NextResponse } from 'next/server';
|
|
import { CompetitionService } from '@/lib/services/database-service';
|
|
|
|
// 獲取競賽的評審團
|
|
export async function GET(request: NextRequest, { params }: { params: { id: string } }) {
|
|
try {
|
|
const { id } = await params;
|
|
|
|
// 獲取競賽信息
|
|
const competition = await CompetitionService.getCompetitionWithDetails(id);
|
|
if (!competition) {
|
|
return NextResponse.json({
|
|
success: false,
|
|
message: '競賽不存在',
|
|
error: '找不到指定的競賽'
|
|
}, { status: 404 });
|
|
}
|
|
|
|
// 獲取競賽的評審團
|
|
const judges = await CompetitionService.getCompetitionJudges(id);
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
message: '競賽評審團獲取成功',
|
|
data: {
|
|
competition,
|
|
judges: judges.map(judge => ({
|
|
id: judge.id,
|
|
name: judge.name,
|
|
title: judge.title,
|
|
department: judge.department,
|
|
expertise: judge.expertise || [],
|
|
avatar: judge.avatar || null,
|
|
email: judge.email,
|
|
phone: judge.phone,
|
|
assignedAt: judge.assigned_at ? new Date(judge.assigned_at).toLocaleDateString('zh-TW') : null
|
|
})),
|
|
total: judges.length
|
|
}
|
|
});
|
|
|
|
} catch (error) {
|
|
console.error('獲取競賽評審團失敗:', error);
|
|
return NextResponse.json({
|
|
success: false,
|
|
message: '獲取競賽評審團失敗',
|
|
error: error instanceof Error ? error.message : '未知錯誤'
|
|
}, { status: 500 });
|
|
}
|
|
}
|