From 57893128b2b50336f63faa1e821bea2efb3717f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B3=E4=BD=A9=E5=BA=AD?= Date: Sat, 27 Sep 2025 21:01:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=8D=8E=E5=8B=B5=E8=B3=87?= =?UTF-8?q?=E8=A8=8A=E8=A9=95=E5=88=86=E8=A9=B3=E7=B4=B0=E5=91=88=E7=8F=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/awards/[id]/scores/route.ts | 40 +++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/app/api/awards/[id]/scores/route.ts b/app/api/awards/[id]/scores/route.ts index 57603b1..9dbba43 100644 --- a/app/api/awards/[id]/scores/route.ts +++ b/app/api/awards/[id]/scores/route.ts @@ -74,18 +74,24 @@ export async function GET( console.log('πŸ” 執葌提摈賽 SQL:', sql, '參數:', [award.proposal_id]); scores = await db.query(sql, [award.proposal_id]); console.log('πŸ“Š 從 proposal_judge_scores η²ε–εˆ°:', scores.length, 'η­†'); - } else if (award.competition_type === 'team' && award.app_id) { - // ζŸ₯θ©’ judge_scores (團隊賽) + } else if (award.competition_type === 'team' && award.app_id) { + // ζŸ₯θ©’ judge_scores (團隊賽) δΈ¦εŒ…ε«θ©•εˆ†θ©³ζƒ… const sql = ` SELECT js.*, j.name as judge_name, j.title as judge_title, j.avatar as judge_avatar, - j.department as judge_department + j.department as judge_department, + GROUP_CONCAT( + CONCAT(jsd.rule_name, ':', jsd.score, ':', jsd.weight) + SEPARATOR '|' + ) as score_details FROM judge_scores js LEFT JOIN judges j ON js.judge_id = j.id + LEFT JOIN judge_score_details jsd ON js.id = jsd.judge_score_id WHERE js.app_id = ? + GROUP BY js.id ORDER BY js.submitted_at DESC `; console.log('πŸ” 執葌團隊賽 SQL:', sql, '參數:', [award.app_id]); @@ -129,19 +135,33 @@ export async function GET( } else if (award.competition_type === 'team') { // judge_scores (團隊賽) ηš„θ™•η† overallScore = score.overall_score || score.total_score || 0; - // ε˜—θ©¦θ§£ζž criteria ζ¬„δ½οΌŒε¦‚ζžœζ²’ζœ‰ε‰‡δ½Ώη”¨ι θ¨­ηš„εœ˜ιšŠθ©•εˆ†ζ¨™ζΊ– - if (score.criteria) { + + // 解析 score_details ζ¬„δ½οΌŒεΎž judge_score_details θ‘¨η²ε–ε‹•ζ…‹θ©•εˆ†η΄°ι … + if (score.score_details) { try { - criteria = typeof score.criteria === 'string' - ? JSON.parse(score.criteria) - : score.criteria; + const details = score.score_details.split('|'); + criteria = details.map((detail: string) => { + const parts = detail.split(':'); + if (parts.length >= 2) { + const ruleName = parts[0]; + const scoreValue = parseFloat(parts[1]) || 0; + const weight = parseFloat(parts[2]) || 1; + return { + name: ruleName, + score: scoreValue, + maxScore: 10, + weight: weight + }; + } + return null; + }).filter(Boolean); } catch (e) { - console.error('解析 criteria ε€±ζ•—:', e); + console.error('解析 score_details ε€±ζ•—:', e); criteria = []; } } - // ε¦‚ζžœζ²’ζœ‰ criteria ζˆ–θ§£ζžε€±ζ•—οΌŒδ½Ώη”¨ι θ¨­ηš„εœ˜ιšŠθ©•εˆ†ζ¨™ζΊ– + // ε¦‚ζžœζ²’ζœ‰ score_details ζˆ–θ§£ζžε€±ζ•—οΌŒδ½Ώη”¨ι θ¨­ηš„εœ˜ιšŠθ©•εˆ†ζ¨™ζΊ– if (!criteria || criteria.length === 0) { criteria = [ { name: '團隊合作', score: score.teamwork_score || 0, maxScore: 10 },