From f04f35b562760afbac0c477357e2a29f77aec3b9 Mon Sep 17 00:00:00 2001 From: lrj <owen.stl@gmail.com> Date: 星期四, 02 十月 2025 13:51:47 +0800 Subject: [PATCH] fix: 修复评审次数重复显示问题 --- backend/src/main/java/com/rongyichuang/player/api/PlayerGraphqlApi.java | 267 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 263 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/com/rongyichuang/player/api/PlayerGraphqlApi.java b/backend/src/main/java/com/rongyichuang/player/api/PlayerGraphqlApi.java index 2859b75..f535211 100644 --- a/backend/src/main/java/com/rongyichuang/player/api/PlayerGraphqlApi.java +++ b/backend/src/main/java/com/rongyichuang/player/api/PlayerGraphqlApi.java @@ -1,40 +1,87 @@ package com.rongyichuang.player.api; +import com.rongyichuang.common.dto.PageResponse; import com.rongyichuang.player.dto.input.ActivityPlayerRatingInput; +import com.rongyichuang.player.dto.ActivityRegistrationInput; import com.rongyichuang.player.dto.response.ActivityPlayerApplicationResponse; import com.rongyichuang.player.dto.response.ActivityPlayerDetailResponse; +import com.rongyichuang.player.dto.response.ProjectReviewApplicationPageResponse; +import com.rongyichuang.player.dto.response.PlayerApplicationPageResponse; +import com.rongyichuang.player.dto.ActivityRegistrationResponse; +import com.rongyichuang.player.dto.response.JudgeRatingStatusResponse; +import com.rongyichuang.player.dto.response.CurrentJudgeRatingResponse; +import com.rongyichuang.player.dto.response.CurrentJudgeInfoResponse; +import com.rongyichuang.player.dto.response.PlayerRegistrationResponse; +import com.rongyichuang.player.dto.PromotionCompetitionResponse; +import com.rongyichuang.player.dto.CompetitionParticipantResponse; +import com.rongyichuang.player.dto.PromotionInput; +import com.rongyichuang.player.dto.PromotionResult; +import com.rongyichuang.player.dto.PromotableParticipantsResponse; import com.rongyichuang.player.service.PlayerApplicationService; import com.rongyichuang.player.service.ActivityPlayerDetailService; import com.rongyichuang.player.service.ActivityPlayerRatingService; +import com.rongyichuang.player.service.ActivityPlayerService; +import com.rongyichuang.player.service.PromotionService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.graphql.data.method.annotation.Argument; import org.springframework.graphql.data.method.annotation.MutationMapping; import org.springframework.graphql.data.method.annotation.QueryMapping; import org.springframework.stereotype.Controller; +import java.math.BigDecimal; import java.util.List; @Controller public class PlayerGraphqlApi { + private static final Logger log = LoggerFactory.getLogger(PlayerGraphqlApi.class); + private final PlayerApplicationService service; private final ActivityPlayerDetailService detailService; private final ActivityPlayerRatingService ratingService; + private final ActivityPlayerService activityPlayerService; + private final PromotionService promotionService; public PlayerGraphqlApi(PlayerApplicationService service, ActivityPlayerDetailService detailService, - ActivityPlayerRatingService ratingService) { + ActivityPlayerRatingService ratingService, + ActivityPlayerService activityPlayerService, + PromotionService promotionService) { this.service = service; this.detailService = detailService; this.ratingService = ratingService; + this.activityPlayerService = activityPlayerService; + this.promotionService = promotionService; } @QueryMapping - public List<ActivityPlayerApplicationResponse> activityPlayerApplications( + public PlayerApplicationPageResponse activityPlayerApplications( @Argument String name, + @Argument Long activityId, + @Argument Integer state, @Argument Integer page, @Argument Integer size ) { - return service.listApplications(name, page, size); + PageResponse<ActivityPlayerApplicationResponse> pageResponse = + service.listApplications(name, activityId, state, page, size); + return PlayerApplicationPageResponse.from(pageResponse); + } + + /** + * 椤圭洰璇勫涓撶敤鏌ヨ锛屽寘鍚墍鏈夐樁娈垫暟鎹紙鍖呮嫭澶嶈禌銆佸喅璧涳級 + */ + @QueryMapping + public ProjectReviewApplicationPageResponse projectReviewApplications( + @Argument String name, + @Argument Long activityId, + @Argument Integer state, + @Argument Integer page, + @Argument Integer size + ) { + PageResponse<ActivityPlayerApplicationResponse> pageResponse = + service.listProjectReviewApplications(name, activityId, state, page, size); + return ProjectReviewApplicationPageResponse.from(pageResponse); } /** @@ -46,10 +93,222 @@ } /** + * 鏌ヨ鐜╁鍦ㄦ寚瀹氭椿鍔ㄤ腑鐨勬姤鍚嶇姸鎬� + */ + @QueryMapping + public PlayerRegistrationResponse playerRegistration(@Argument Long activityId) { + return activityPlayerService.getPlayerRegistration(activityId); + } + + /** * 淇濆瓨姣旇禌鎶ュ悕璇勫垎 */ @MutationMapping public Boolean saveActivityPlayerRating(@Argument ActivityPlayerRatingInput input) { - return ratingService.saveRating(input); + log.info("鏀跺埌璇勫垎淇濆瓨璇锋眰锛宎ctivityPlayerId: {}, ratings count: {}", + input.getActivityPlayerId(), input.getRatings() != null ? input.getRatings().size() : 0); + try { + Boolean result = ratingService.saveRating(input); + log.info("璇勫垎淇濆瓨缁撴灉: {}", result); + return result; + } catch (Exception e) { + log.error("GraphQL API 灞傛崟鑾峰紓甯�: {}", e.getMessage(), e); + throw e; + } + } + + /** + * 鑾峰彇鎸囧畾閫夋墜鐨勬墍鏈夎瘎濮旇瘎鍒嗙姸鎬� + */ + @QueryMapping + public List<JudgeRatingStatusResponse> judgeRatingsForPlayer(@Argument Long activityPlayerId) { + log.info("鑾峰彇閫夋墜璇勫璇勫垎鐘舵�侊紝activityPlayerId: {}", activityPlayerId); + return ratingService.getAllJudgeRatingsForPlayer(activityPlayerId); + } + + /** + * 鑾峰彇褰撳墠璇勫瀵规寚瀹氶�夋墜鐨勮瘎鍒� + */ + @QueryMapping + public CurrentJudgeRatingResponse currentJudgeRating(@Argument Long activityPlayerId) { + log.info("鑾峰彇褰撳墠璇勫璇勫垎锛宎ctivityPlayerId: {}", activityPlayerId); + return ratingService.getCurrentJudgeRating(activityPlayerId); + } + + /** + * 鑾峰彇鎸囧畾閫夋墜鐨勫钩鍧囧垎 + */ + @QueryMapping + public BigDecimal averageScoreForPlayer(@Argument Long activityPlayerId) { + log.info("鑾峰彇閫夋墜骞冲潎鍒嗭紝activityPlayerId: {}", activityPlayerId); + return ratingService.getAverageScoreForPlayer(activityPlayerId); + } + + /** + * 鑾峰彇褰撳墠璇勫淇℃伅 + */ + @QueryMapping + public CurrentJudgeInfoResponse currentJudgeInfo() { + log.info("鑾峰彇褰撳墠璇勫淇℃伅"); + return ratingService.getCurrentJudgeInfo(); + } + + /** + * 妫�鏌ヨ瘎濮旀槸鍚﹀湪鎸囧畾姣旇禌闃舵鐨勮瘎濮斿垪琛ㄤ腑 + */ + @QueryMapping + public Boolean isJudgeInActivity(@Argument Long stageId, @Argument Long judgeId) { + log.info("妫�鏌ヨ瘎濮旀潈闄愶紝stageId: {}, judgeId: {}", stageId, judgeId); + return ratingService.isJudgeInActivity(stageId, judgeId); + } + + /** + * 鑾峰彇鎸囧畾璇勫鐨勮瘎鍒嗘槑缁� + */ + @QueryMapping + public CurrentJudgeRatingResponse judgeRatingDetail(@Argument Long activityPlayerId, @Argument Long judgeId) { + log.info("鑾峰彇鎸囧畾璇勫璇勫垎鏄庣粏锛宎ctivityPlayerId: {}, judgeId: {}", activityPlayerId, judgeId); + return ratingService.getJudgeRatingDetail(activityPlayerId, judgeId); + } + + /** + * 鎻愪氦娲诲姩鎶ュ悕 + */ + @MutationMapping + public ActivityRegistrationResponse submitActivityRegistration(@Argument ActivityRegistrationInput input) { + log.info("鏀跺埌娲诲姩鎶ュ悕璇锋眰锛宎ctivityId: {}, playerName: {}", + input.getActivityId(), input.getPlayerInfo().getName()); + try { + ActivityRegistrationResponse result = activityPlayerService.submitActivityRegistration(input); + log.info("娲诲姩鎶ュ悕缁撴灉: {}", result.getSuccess()); + return result; + } catch (Exception e) { + log.error("娲诲姩鎶ュ悕澶辫触: {}", e.getMessage(), e); + // 杩斿洖澶辫触鍝嶅簲 + ActivityRegistrationResponse response = new ActivityRegistrationResponse(); + response.setSuccess(false); + response.setMessage("鎶ュ悕澶辫触: " + e.getMessage()); + return response; + } + } + + /** + * 瀹℃牳閫氳繃 + */ + @MutationMapping + public Boolean approveActivityPlayer(@Argument Long activityPlayerId, @Argument String feedback) { + log.info("瀹℃牳閫氳繃璇锋眰锛宎ctivityPlayerId: {}, feedback: {}", activityPlayerId, feedback); + try { + return activityPlayerService.approveActivityPlayer(activityPlayerId, feedback); + } catch (Exception e) { + log.error("瀹℃牳閫氳繃澶辫触: {}", e.getMessage(), e); + throw e; + } + } + + /** + * 瀹℃牳椹冲洖 + */ + @MutationMapping + public Boolean rejectActivityPlayer(@Argument Long activityPlayerId, @Argument String feedback) { + log.info("瀹℃牳椹冲洖璇锋眰锛宎ctivityPlayerId: {}, feedback: {}", activityPlayerId, feedback); + try { + return activityPlayerService.rejectActivityPlayer(activityPlayerId, feedback); + } catch (Exception e) { + log.error("瀹℃牳椹冲洖澶辫触: {}", e.getMessage(), e); + throw e; + } + } + + /** + * 鏇存柊瀹℃牳鎰忚 + */ + @MutationMapping + public Boolean updatePlayerFeedback(@Argument Long activityPlayerId, @Argument String feedback) { + log.info("鏇存柊瀹℃牳鎰忚璇锋眰锛宎ctivityPlayerId: {}, feedback: {}", activityPlayerId, feedback); + try { + return activityPlayerService.updateFeedback(activityPlayerId, feedback); + } catch (Exception e) { + log.error("鏇存柊瀹℃牳鎰忚澶辫触: {}", e.getMessage(), e); + throw e; + } + } + + @MutationMapping + public ActivityRegistrationResponse updateActivityRegistration(@Argument Long activityPlayerId, @Argument ActivityRegistrationInput input) { + try { + log.info("鏀跺埌鏇存柊鎶ュ悕璇锋眰锛屾姤鍚岻D: {}", activityPlayerId); + return activityPlayerService.updateActivityRegistration(activityPlayerId, input); + } catch (Exception e) { + log.error("鏇存柊鎶ュ悕澶辫触", e); + ActivityRegistrationResponse response = new ActivityRegistrationResponse(); + response.setSuccess(false); + response.setMessage("鏇存柊鎶ュ悕澶辫触: " + e.getMessage()); + return response; + } + } + + /** + * 鑾峰彇姣旇禌鏅嬬骇鍒楄〃 + */ + @QueryMapping + public List<PromotionCompetitionResponse> promotionCompetitions( + @Argument String name, + @Argument Integer page, + @Argument Integer size) { + try { + log.info("鑾峰彇姣旇禌鏅嬬骇鍒楄〃锛屽悕绉拌繃婊�: {}, 椤电爜: {}, 椤靛ぇ灏�: {}", name, page, size); + return promotionService.getPromotionCompetitions(name, page, size); + } catch (Exception e) { + log.error("鑾峰彇姣旇禌鏅嬬骇鍒楄〃澶辫触: {}", e.getMessage(), e); + throw e; + } + } + + /** + * 鑾峰彇姣旇禌鍙傝禌浜哄憳 + */ + @QueryMapping + public List<CompetitionParticipantResponse> competitionParticipants( + @Argument Long competitionId, + @Argument Integer page, + @Argument Integer size) { + try { + log.info("鑾峰彇姣旇禌鍙傝禌浜哄憳锛屾瘮璧汭D: {}, 椤电爜: {}, 椤靛ぇ灏�: {}", competitionId, page, size); + return promotionService.getCompetitionParticipants(competitionId, page, size); + } catch (Exception e) { + log.error("鑾峰彇姣旇禌鍙傝禌浜哄憳澶辫触: {}", e.getMessage(), e); + throw e; + } + } + + /** + * 鑾峰彇鍙檵绾у弬璧涜�呭垪琛� + */ + @QueryMapping + public PromotableParticipantsResponse promotableParticipants(@Argument Long currentStageId) { + try { + log.info("鑾峰彇鍙檵绾у弬璧涜�呭垪琛紝褰撳墠闃舵ID: {}", currentStageId); + return promotionService.getPromotableParticipants(currentStageId); + } catch (Exception e) { + log.error("鑾峰彇鍙檵绾у弬璧涜�呭垪琛ㄥけ璐�: {}", e.getMessage(), e); + throw e; + } + } + + /** + * 鎵ц鏅嬬骇鎿嶄綔 + */ + @MutationMapping + public PromotionResult promoteParticipants(@Argument PromotionInput input) { + try { + log.info("鎵ц鏅嬬骇鎿嶄綔锛屾瘮璧汭D: {}, 鍙傝禌鑰呮暟閲�: {}", + input.getCompetitionId(), + input.getParticipantIds() != null ? input.getParticipantIds().size() : 0); + return promotionService.promoteParticipants(input); + } catch (Exception e) { + log.error("鎵ц鏅嬬骇鎿嶄綔澶辫触: {}", e.getMessage(), e); + return PromotionResult.failure("鏅嬬骇鎿嶄綔澶辫触: " + e.getMessage()); + } } } \ No newline at end of file -- Gitblit v1.8.0