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.judge.api;
 
import com.rongyichuang.judge.dto.request.JudgeInput;
import com.rongyichuang.judge.dto.response.JudgeResponse;
import com.rongyichuang.judge.service.JudgeService;
import com.rongyichuang.common.dto.request.MediaInput;
import com.rongyichuang.common.dto.response.MediaResponse;
import com.rongyichuang.common.service.MediaService;
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 org.springframework.web.multipart.MultipartFile;
 
import java.util.List;
 
@Controller
public class JudgeGraphqlApi {
 
    private final JudgeService judgeService;
    private final MediaService mediaService;
 
    public JudgeGraphqlApi(JudgeService judgeService, MediaService mediaService) {
        this.judgeService = judgeService;
        this.mediaService = mediaService;
    }
 
    @QueryMapping
    public List<JudgeResponse> judges() {
        return judgeService.findAll();
    }
 
    @QueryMapping
    public List<JudgeResponse> judgesByName(@Argument String name) {
        return judgeService.findByName(name);
    }
 
    @QueryMapping
    public JudgeResponse judge(@Argument Long id) {
        return judgeService.findById(id);
    }
 
    @MutationMapping
    public JudgeResponse saveJudge(@Argument JudgeInput input) {
        return judgeService.save(input);
    }
 
    @MutationMapping
    public Boolean deleteJudge(@Argument Long id) {
        judgeService.delete(id);
        return true;
    }
 
 
}