lrj
1 天以前 93eb6b470773bc49ea6e1a9d4cbd914eb95d525b
backend/src/main/java/com/rongyichuang/player/api/PlayerGraphqlApi.java
@@ -1,14 +1,24 @@
package com.rongyichuang.player.api;
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.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;
@@ -27,23 +37,30 @@
    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(
            @Argument String name,
            @Argument Long activityId,
            @Argument Integer state,
            @Argument Integer page,
            @Argument Integer size
    ) {
        return service.listApplications(name, activityId, page, size);
        return service.listApplications(name, activityId, state, page, size);
    }
    /**
@@ -52,6 +69,14 @@
    @QueryMapping
    public ActivityPlayerDetailResponse activityPlayerDetail(@Argument Long id) {
        return detailService.getDetailForRating(id);
    }
    /**
     * 查询玩家在指定活动中的报名状态
     */
    @QueryMapping
    public PlayerRegistrationResponse playerRegistration(@Argument Long activityId) {
        return activityPlayerService.getPlayerRegistration(activityId);
    }
    /**
@@ -106,4 +131,145 @@
        log.info("获取当前评委信息");
        return ratingService.getCurrentJudgeInfo();
    }
    /**
     * 提交活动报名
     */
    @MutationMapping
    public ActivityRegistrationResponse submitActivityRegistration(@Argument ActivityRegistrationInput input) {
        log.info("收到活动报名请求,activityId: {}, 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("审核通过请求,activityPlayerId: {}, 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("审核驳回请求,activityPlayerId: {}, 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("更新审核意见请求,activityPlayerId: {}, 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("收到更新报名请求,报名ID: {}", 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("获取比赛参赛人员,比赛ID: {}, 页码: {}, 页大小: {}", 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("执行晋级操作,比赛ID: {}, 参赛者数量: {}",
                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());
        }
    }
}