新增競賽前台呈現、刪除競賽、修改競賽狀態
This commit is contained in:
45
app/api/debug/competitions/route.ts
Normal file
45
app/api/debug/competitions/route.ts
Normal 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 allCompetitions = await CompetitionService.getAllCompetitions();
|
||||
|
||||
// 獲取當前競賽
|
||||
const currentCompetition = await CompetitionService.getCurrentCompetition();
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: {
|
||||
allCompetitions: allCompetitions.map(c => ({
|
||||
id: c.id,
|
||||
name: c.name,
|
||||
status: c.status,
|
||||
is_current: c.is_current,
|
||||
is_active: c.is_active
|
||||
})),
|
||||
currentCompetition: currentCompetition ? {
|
||||
id: currentCompetition.id,
|
||||
name: currentCompetition.name,
|
||||
status: currentCompetition.status,
|
||||
is_current: currentCompetition.is_current,
|
||||
is_active: currentCompetition.is_active
|
||||
} : null
|
||||
}
|
||||
});
|
||||
|
||||
} 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