| | |
| | | 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.service.PlayerApplicationService; |
| | | import com.rongyichuang.player.service.ActivityPlayerDetailService; |
| | | import com.rongyichuang.player.service.ActivityPlayerRatingService; |
| | | import com.rongyichuang.player.service.ActivityPlayerService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.graphql.data.method.annotation.Argument; |
| | |
| | | private final PlayerApplicationService service; |
| | | private final ActivityPlayerDetailService detailService; |
| | | private final ActivityPlayerRatingService ratingService; |
| | | private final ActivityPlayerService activityPlayerService; |
| | | |
| | | public PlayerGraphqlApi(PlayerApplicationService service, |
| | | ActivityPlayerDetailService detailService, |
| | | ActivityPlayerRatingService ratingService) { |
| | | ActivityPlayerRatingService ratingService, |
| | | ActivityPlayerService activityPlayerService) { |
| | | this.service = service; |
| | | this.detailService = detailService; |
| | | this.ratingService = ratingService; |
| | | this.activityPlayerService = activityPlayerService; |
| | | } |
| | | |
| | | @QueryMapping |
| | |
| | | @QueryMapping |
| | | public ActivityPlayerDetailResponse activityPlayerDetail(@Argument Long id) { |
| | | return detailService.getDetailForRating(id); |
| | | } |
| | | |
| | | /** |
| | | * 查询玩家在指定活动中的报名状态 |
| | | */ |
| | | @QueryMapping |
| | | public PlayerRegistrationResponse playerRegistration(@Argument Long activityId) { |
| | | return activityPlayerService.getPlayerRegistration(activityId); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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; |
| | | } |
| | | } |
| | | } |