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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package com.rongyichuang.review.resolver;
 
import com.rongyichuang.common.util.UserContextUtil;
import com.rongyichuang.review.dto.response.ReviewProjectPageResponse;
import com.rongyichuang.review.dto.response.ReviewProjectResponse;
import com.rongyichuang.review.dto.response.ReviewStatisticsResponse;
import com.rongyichuang.review.service.ReviewService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.graphql.data.method.annotation.Argument;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.stereotype.Controller;
 
/**
 * 评审管理GraphQL解析器
 */
@Controller
public class ReviewResolver {
 
    private static final Logger log = LoggerFactory.getLogger(ReviewResolver.class);
 
    @Autowired
    private ReviewService reviewService;
 
    @Autowired
    private UserContextUtil userContextUtil;
 
    /**
     * 查询我未评审的项目列表
     */
    @QueryMapping
    public ReviewProjectPageResponse unReviewedProjects(
            @Argument String searchKeyword,
            @Argument int page,
            @Argument int pageSize) {
        log.info("查询我未评审的项目列表,searchKeyword: {}, page: {}, pageSize: {}", searchKeyword, page, pageSize);
        
        Long currentJudgeId = userContextUtil.getCurrentJudgeId();
        if (currentJudgeId == null) {
            throw new RuntimeException("当前用户不是评委,无法查询评审项目");
        }
        
        return reviewService.getUnReviewedProjects(currentJudgeId, searchKeyword, page, pageSize);
    }
 
    /**
     * 查询我已评审的项目列表
     */
    @QueryMapping
    public ReviewProjectPageResponse reviewedProjects(
            @Argument String searchKeyword,
            @Argument int page,
            @Argument int pageSize) {
        log.info("查询我已评审的项目列表,searchKeyword: {}, page: {}, pageSize: {}", searchKeyword, page, pageSize);
        
        Long currentJudgeId = userContextUtil.getCurrentJudgeId();
        if (currentJudgeId == null) {
            throw new RuntimeException("当前用户不是评委,无法查询评审项目");
        }
        
        return reviewService.getReviewedProjects(currentJudgeId, searchKeyword, page, pageSize);
    }
 
    /**
     * 查询学员未评审的项目列表
     */
    @QueryMapping
    public ReviewProjectPageResponse studentUnReviewedProjects(
            @Argument String searchKeyword,
            @Argument int page,
            @Argument int pageSize) {
        log.info("查询学员未评审的项目列表,searchKeyword: {}, page: {}, pageSize: {}", searchKeyword, page, pageSize);
        
        Long currentJudgeId = userContextUtil.getCurrentJudgeId();
        if (currentJudgeId == null) {
            throw new RuntimeException("当前用户不是评委,无法查询评审项目");
        }
        
        return reviewService.getStudentUnReviewedProjects(currentJudgeId, searchKeyword, page, pageSize);
    }
 
    /**
     * 查询评审统计信息
     */
    @QueryMapping
    public ReviewStatisticsResponse reviewStatistics() {
        log.info("查询评审统计信息");
        
        Long currentJudgeId = userContextUtil.getCurrentJudgeId();
        if (currentJudgeId == null) {
            throw new RuntimeException("当前用户不是评委,无法查询评审统计");
        }
        
        return reviewService.getReviewStatistics(currentJudgeId);
    }
}