lrj
2 天以前 c61d4fe27c97d2ecc907756aa571a4ef14a7b9b6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.rongyichuang.player.api;
 
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.service.PlayerApplicationService;
import com.rongyichuang.player.service.ActivityPlayerDetailService;
import com.rongyichuang.player.service.ActivityPlayerRatingService;
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.util.List;
 
@Controller
public class PlayerGraphqlApi {
 
    private final PlayerApplicationService service;
    private final ActivityPlayerDetailService detailService;
    private final ActivityPlayerRatingService ratingService;
 
    public PlayerGraphqlApi(PlayerApplicationService service,
                           ActivityPlayerDetailService detailService,
                           ActivityPlayerRatingService ratingService) {
        this.service = service;
        this.detailService = detailService;
        this.ratingService = ratingService;
    }
 
    @QueryMapping
    public List<ActivityPlayerApplicationResponse> activityPlayerApplications(
            @Argument String name,
            @Argument Integer page,
            @Argument Integer size
    ) {
        return service.listApplications(name, page, size);
    }
 
    /**
     * 获取比赛报名详情(用于评分)
     */
    @QueryMapping
    public ActivityPlayerDetailResponse activityPlayerDetail(@Argument Long id) {
        return detailService.getDetailForRating(id);
    }
 
    /**
     * 保存比赛报名评分
     */
    @MutationMapping
    public Boolean saveActivityPlayerRating(@Argument ActivityPlayerRatingInput input) {
        return ratingService.saveRating(input);
    }
}