diff --git a/app/api/admin/awards/route.ts b/app/api/admin/awards/route.ts index ffb55cf..d286eeb 100644 --- a/app/api/admin/awards/route.ts +++ b/app/api/admin/awards/route.ts @@ -140,7 +140,11 @@ export async function GET(request: NextRequest) { id: award.id, competition_name: (award as any).competition_name, competition_type: (award as any).competition_type, - competition_id: award.competition_id + competition_id: award.competition_id, + team_name_from_teams: (award as any).team_name_from_teams, + team_name: (award as any).team_name, + app_name: (award as any).app_name, + team_id: (award as any).team_id }); return { @@ -156,9 +160,9 @@ export async function GET(request: NextRequest) { awardType: award.award_type, teamName: (award as any).team_name_from_teams || award.team_name, appName: award.app_name, - applicationLinks: award.application_links ? JSON.parse(award.application_links) : null, - documents: award.documents ? JSON.parse(award.documents) : [], - photos: award.photos ? JSON.parse(award.photos) : [], + applicationLinks: (award as any).application_links ? JSON.parse((award as any).application_links) : null, + documents: (award as any).documents ? JSON.parse((award as any).documents) : [], + photos: (award as any).photos ? JSON.parse((award as any).photos) : [], }; }); diff --git a/app/competition/page.tsx b/app/competition/page.tsx index 4833658..4b7cec7 100644 --- a/app/competition/page.tsx +++ b/app/competition/page.tsx @@ -398,7 +398,7 @@ export default function CompetitionPage() { {monthAwards.map((award) => ( handleShowAwardDetail(award)} > {/* Rank Badge */} @@ -422,7 +422,7 @@ export default function CompetitionPage() {
{award.icon}
- +
- - {award.competitionType === "team" - ? (award.teamName || "團隊名稱") - : (award.appName || award.proposalTitle || "應用名稱") - } + + {(() => { + console.log('🔍 獎項資料:', { + id: award.id, + competitionType: award.competitionType, + teamName: award.teamName, + appName: award.appName, + proposalTitle: award.proposalTitle, + team_name: (award as any).team_name, + team_name_from_teams: (award as any).team_name_from_teams + }); + + // 團體賽優先顯示團隊名稱 + if (award.competitionType === "team") { + // 優先使用從teams表查詢的團隊名稱,其次使用獎項表中的團隊名稱 + const teamName = (award as any).team_name_from_teams || award.teamName || (award as any).team_name; + return teamName || "團隊名稱"; + } + + // 提案賽顯示提案標題 + if (award.competitionType === "proposal") { + return award.proposalTitle || "提案標題"; + } + + // 個人賽顯示應用名稱 + return award.appName || "應用名稱"; + })()}

by {award.creator}

@@ -463,8 +485,8 @@ export default function CompetitionPage() {
- -
+ +
{award.competitionType === "proposal" @@ -483,17 +505,17 @@ export default function CompetitionPage() { : award.score}
- -
+ +
))} diff --git a/app/page.tsx b/app/page.tsx index 47307b7..e72ce9c 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -798,7 +798,7 @@ export default function AIShowcasePlatform() { {monthAwards.map((award) => ( handleShowAwardDetail(award)} > {/* Rank Badge */} @@ -822,7 +822,7 @@ export default function AIShowcasePlatform() {
{award.icon}
- +
- - {award.appName || award.awardName} + + {(() => { + // 團體賽優先顯示團隊名稱 + if (award.competitionType === "team") { + const teamName = (award as any).team_name_from_teams || award.teamName || (award as any).team_name; + return teamName || "團隊名稱"; + } + + // 提案賽顯示提案標題 + if (award.competitionType === "proposal") { + return award.proposalTitle || "提案標題"; + } + + // 個人賽顯示應用名稱 + return award.appName || award.awardName || "應用名稱"; + })()}

by {award.creator}

@@ -860,8 +874,8 @@ export default function AIShowcasePlatform() {
- -
+ +
{award.awardType === "popular" @@ -878,17 +892,17 @@ export default function AIShowcasePlatform() { : award.score}
- -
+ +
))} diff --git a/components/admin/competition-management.tsx b/components/admin/competition-management.tsx index 6f61099..7febc49 100644 --- a/components/admin/competition-management.tsx +++ b/components/admin/competition-management.tsx @@ -4046,12 +4046,12 @@ export function CompetitionManagement() { const paginatedAwards = filteredAwards.slice(startIndex, endIndex) return ( -
+
{paginatedAwards.map((award: any) => ( - +
{award.icon}
- -
+ +
{/* 獎項基本資訊 */}
{award.award_name} -

- {award.team_name || award.app_name || "作品"} +

+ {(() => { + // 團體賽優先顯示團隊名稱 + if (award.competition_type === "team") { + const teamName = award.team_name_from_teams || award.team_name; + return teamName || "團隊名稱"; + } + + // 提案賽顯示提案標題 + if (award.competition_type === "proposal") { + return award.proposal_title || "提案標題"; + } + + // 個人賽顯示應用名稱 + return award.app_name || "應用名稱"; + })()}

by {award.creator}

@@ -8811,7 +8825,21 @@ export function CompetitionManagement() {

{selectedAward.awardName}

- {(selectedAward as any).app_name || (selectedAward as any).team_name || "團隊作品"} • by {selectedAward.creator} + {(() => { + // 團體賽優先顯示團隊名稱 + if (selectedAward.competitionType === "team") { + const teamName = (selectedAward as any).team_name_from_teams || (selectedAward as any).team_name; + return teamName || "團隊名稱"; + } + + // 提案賽顯示提案標題 + if (selectedAward.competitionType === "proposal") { + return (selectedAward as any).proposal_title || "提案標題"; + } + + // 個人賽顯示應用名稱 + return (selectedAward as any).app_name || "應用名稱"; + })()} • by {selectedAward.creator}

diff --git a/lib/services/database-service.ts b/lib/services/database-service.ts index 2cbcf3e..db9754c 100644 --- a/lib/services/database-service.ts +++ b/lib/services/database-service.ts @@ -4597,7 +4597,11 @@ export class AwardService extends DatabaseServiceBase { id: result[0].id, competition_name: (result[0] as any).competition_name, competition_type: (result[0] as any).competition_type, - competition_id: result[0].competition_id + competition_id: result[0].competition_id, + team_name_from_teams: (result[0] as any).team_name_from_teams, + team_name: (result[0] as any).team_name, + app_name: (result[0] as any).app_name, + team_id: (result[0] as any).team_id }); } @@ -4698,7 +4702,21 @@ export class AwardService extends DatabaseServiceBase { // 根據年份獲取獎項 static async getAwardsByYear(year: number): Promise { - const sql = 'SELECT * FROM awards WHERE year = ? ORDER BY month DESC, rank ASC'; + const sql = ` + SELECT + a.*, + c.name as competition_name, + c.type as competition_type, + c.description as competition_description, + c.start_date as competition_start_date, + c.end_date as competition_end_date, + t.name as team_name_from_teams + FROM awards a + LEFT JOIN competitions c ON a.competition_id = c.id + LEFT JOIN teams t ON a.team_id = t.id + WHERE a.year = ? + ORDER BY a.month DESC, a.rank ASC + `; return await db.query(sql, [year]); }