新增 競賽建立、評審建立、團隊建立

This commit is contained in:
2025-09-15 13:32:30 +08:00
parent b85a9ce95e
commit 31ffaa1974
31 changed files with 5163 additions and 455 deletions

View File

@@ -0,0 +1,45 @@
// =====================================================
// 競賽統計 API
// =====================================================
import { NextRequest, NextResponse } from 'next/server';
import { CompetitionService } from '@/lib/services/database-service';
// 獲取競賽統計數據
export async function GET(request: NextRequest) {
try {
const competitions = await CompetitionService.getAllCompetitions();
// 計算統計數據
const stats = {
total: competitions.length,
upcoming: competitions.filter(c => c.status === 'upcoming').length,
active: competitions.filter(c => c.status === 'active').length,
judging: competitions.filter(c => c.status === 'judging').length,
completed: competitions.filter(c => c.status === 'completed').length,
individual: competitions.filter(c => c.type === 'individual').length,
team: competitions.filter(c => c.type === 'team').length,
mixed: competitions.filter(c => c.type === 'mixed').length,
proposal: competitions.filter(c => c.type === 'proposal').length,
currentYear: competitions.filter(c => c.year === new Date().getFullYear()).length,
thisMonth: competitions.filter(c =>
c.year === new Date().getFullYear() &&
c.month === new Date().getMonth() + 1
).length
};
return NextResponse.json({
success: true,
message: '競賽統計獲取成功',
data: stats
});
} catch (error) {
console.error('獲取競賽統計失敗:', error);
return NextResponse.json({
success: false,
message: '獲取競賽統計失敗',
error: error instanceof Error ? error.message : '未知錯誤'
}, { status: 500 });
}
}