From ba94ceae1315174798ae1967ef62268c6d16cd5b Mon Sep 17 00:00:00 2001
From: Codex Assistant <codex@example.com>
Date: 星期一, 06 十月 2025 22:07:06 +0800
Subject: [PATCH] feat: 评审与活动相关改动 - backend(GraphQL): Activity schema 增加 updateActivityState(id, state);实现 resolver/service 仅更新 state=2 作为逻辑删除 - backend(GraphQL): region.graphqls 新增 Query leafRegions - backend(GraphQL): player.graphqls 的 projectReviewApplications 增加可选参数 regionId - backend(Service): listProjectReviewApplications 绑定 regionId 参数,修复 QueryParameterException - frontend(web): 新增 api/activity.js 的 updateActivityState 并接入 activity-list 删除逻辑 - frontend(web): review-list.vue 权限仅校验登录,移除角色限制;查询参数修正为 name/regionId - frontend(web): 删除未引用的 ActivityList.vue - frontend(web): projectReviewNew.js GraphQL 查询增加 name 参数

---
 backend/src/main/java/com/rongyichuang/player/service/ActivityPlayerRatingService.java |   53 ++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 42 insertions(+), 11 deletions(-)

diff --git a/backend/src/main/java/com/rongyichuang/player/service/ActivityPlayerRatingService.java b/backend/src/main/java/com/rongyichuang/player/service/ActivityPlayerRatingService.java
index 3ddffc1..94615e1 100644
--- a/backend/src/main/java/com/rongyichuang/player/service/ActivityPlayerRatingService.java
+++ b/backend/src/main/java/com/rongyichuang/player/service/ActivityPlayerRatingService.java
@@ -206,7 +206,10 @@
      */
     public CurrentJudgeRatingResponse getCurrentJudgeRating(Long activityPlayerId) {
         Long currentJudgeId = userContextUtil.getCurrentJudgeId();
+        log.info("getCurrentJudgeRating - activityPlayerId: {}, currentJudgeId: {}", activityPlayerId, currentJudgeId);
+        
         if (currentJudgeId == null) {
+            log.warn("getCurrentJudgeRating - currentJudgeId is null");
             return null;
         }
         
@@ -214,8 +217,11 @@
                 .findByActivityPlayerIdAndJudgeId(activityPlayerId, currentJudgeId);
         
         if (!ratingOpt.isPresent()) {
+            log.info("getCurrentJudgeRating - No rating found for activityPlayerId: {} and judgeId: {}", activityPlayerId, currentJudgeId);
             return null;
         }
+        
+        log.info("getCurrentJudgeRating - Found rating with id: {}", ratingOpt.get().getId());
         
         ActivityPlayerRating rating = ratingOpt.get();
         CurrentJudgeRatingResponse response = new CurrentJudgeRatingResponse();
@@ -227,16 +233,35 @@
         // 鑾峰彇璇勫垎椤�
         List<ActivityPlayerRatingItem> items = activityPlayerRatingItemRepository
                 .findByActivityPlayerRatingId(rating.getId());
-        
-        List<CurrentJudgeRatingResponse.CurrentJudgeRatingItemResponse> itemResponses = items.stream()
-                .map(item -> new CurrentJudgeRatingResponse.CurrentJudgeRatingItemResponse(
-                        item.getRatingItemId(),
-                        "", // 璇勫垎椤瑰悕绉版殏鏃朵负绌�
-                        item.getScore(),
-                        item.getScore() // 浣跨敤寰楀垎浣滀负鍔犳潈寰楀垎
-                ))
+
+        List<Long> ratingItemIds = items.stream()
+                .map(ActivityPlayerRatingItem::getRatingItemId)
+                .filter(java.util.Objects::nonNull)
+                .distinct()
                 .collect(java.util.stream.Collectors.toList());
-        
+
+        java.util.Map<Long, RatingItem> ratingItemMap = ratingItemIds.isEmpty()
+                ? java.util.Collections.emptyMap()
+                : ratingItemRepository.findAllById(ratingItemIds).stream()
+                        .collect(java.util.stream.Collectors.toMap(RatingItem::getId, java.util.function.Function.identity()));
+
+        List<CurrentJudgeRatingResponse.CurrentJudgeRatingItemResponse> itemResponses = items.stream()
+                .map(item -> {
+                    RatingItem ratingItem = ratingItemMap.get(item.getRatingItemId());
+                    String name = ratingItem != null ? ratingItem.getName() : "";
+                    BigDecimal maxScore = ratingItem != null && ratingItem.getMaxScore() != null
+                            ? BigDecimal.valueOf(ratingItem.getMaxScore()) : null;
+                    return new CurrentJudgeRatingResponse.CurrentJudgeRatingItemResponse(
+                            item.getRatingItemId(),
+                            name,
+                            item.getScore(),
+                            item.getScore(),
+                            maxScore
+                    );
+                })
+                .collect(java.util.stream.Collectors.toList());
+
+        response.setRatedAt(rating.getUpdateTime() != null ? rating.getUpdateTime().toString() : null);
         response.setItems(itemResponses);
         return response;
     }
@@ -397,7 +422,12 @@
                             ((Number) row.get("rating_item_id")).longValue(),
                             (String) row.get("rating_item_name"),
                             (BigDecimal) row.get("score"),
-                            (BigDecimal) row.get("score") // weightedScore 鏆傛椂浣跨敤鐩稿悓鍊�
+                            (BigDecimal) row.get("score"),
+                            row.get("max_score") instanceof BigDecimal
+                                    ? (BigDecimal) row.get("max_score")
+                                    : row.get("max_score") instanceof Number
+                                        ? BigDecimal.valueOf(((Number) row.get("max_score")).doubleValue())
+                                        : null
                     ))
                     .collect(java.util.stream.Collectors.toList());
             
@@ -406,6 +436,7 @@
             response.setTotalScore(rating.getTotalScore());
             response.setStatus(rating.getState());
             response.setRemark(rating.getFeedback());
+            response.setRatedAt(rating.getUpdateTime() != null ? rating.getUpdateTime().toString() : null);
             response.setItems(items);
             
             return response;
@@ -415,4 +446,4 @@
             return null;
         }
     }
-}
\ No newline at end of file
+}

--
Gitblit v1.8.0