lrj
7 天以前 4fa9591629721797386fc11836e3a9deb69cd58c
backend/src/main/java/com/rongyichuang/player/api/PlayerGraphqlApi.java
@@ -3,18 +3,26 @@
import com.rongyichuang.player.dto.input.ActivityPlayerRatingInput;
import com.rongyichuang.player.dto.response.ActivityPlayerApplicationResponse;
import com.rongyichuang.player.dto.response.ActivityPlayerDetailResponse;
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.service.PlayerApplicationService;
import com.rongyichuang.player.service.ActivityPlayerDetailService;
import com.rongyichuang.player.service.ActivityPlayerRatingService;
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;
@@ -31,10 +39,11 @@
    @QueryMapping
    public List<ActivityPlayerApplicationResponse> activityPlayerApplications(
            @Argument String name,
            @Argument Long activityId,
            @Argument Integer page,
            @Argument Integer size
    ) {
        return service.listApplications(name, page, size);
        return service.listApplications(name, activityId, page, size);
    }
    /**
@@ -50,6 +59,51 @@
     */
    @MutationMapping
    public Boolean saveActivityPlayerRating(@Argument ActivityPlayerRatingInput input) {
        return ratingService.saveRating(input);
        log.info("收到评分保存请求,activityPlayerId: {}, 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("获取当前评委评分,activityPlayerId: {}", 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();
    }
}