前台競賽功能修復

This commit is contained in:
2025-09-18 09:04:47 +08:00
parent 6ce0b250cb
commit 2101767690
4 changed files with 43 additions and 11 deletions

View File

@@ -1275,7 +1275,26 @@ export class CompetitionService {
// 獲取所有競賽
static async getAllCompetitions(): Promise<Competition[]> {
const sql = 'SELECT * FROM competitions WHERE is_active = TRUE ORDER BY year DESC, month DESC';
return await db.query<Competition>(sql);
const competitions = await db.query<any>(sql);
// 轉換字段名稱以匹配前端期望的格式
return competitions.map(competition => ({
...competition,
startDate: competition.start_date,
endDate: competition.end_date,
evaluationFocus: competition.evaluation_focus,
maxTeamSize: competition.max_team_size,
isActive: competition.is_active,
createdAt: competition.created_at,
updatedAt: competition.updated_at,
// 添加默認的空數組,因為這些字段在競賽列表中不需要詳細數據
judges: [],
participatingApps: [],
participatingTeams: [],
participatingProposals: [],
rules: [],
awardTypes: []
}));
}
// 獲取競賽統計