完成評審評分機制
This commit is contained in:
39
app/api/admin/scoring/stats/route.ts
Normal file
39
app/api/admin/scoring/stats/route.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
// =====================================================
|
||||
// 評分統計 API
|
||||
// =====================================================
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { ScoringService } from '@/lib/services/database-service';
|
||||
|
||||
// 獲取評分統計數據
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const competitionId = searchParams.get('competitionId');
|
||||
|
||||
if (!competitionId) {
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: '缺少競賽ID',
|
||||
error: 'competitionId 參數是必需的'
|
||||
}, { status: 400 });
|
||||
}
|
||||
|
||||
// 獲取評分統計
|
||||
const stats = await ScoringService.getCompetitionScoreStats(competitionId);
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user