Codex Assistant
2025-11-06 375c18a6d2713ff19b22093eec57315992d8333f
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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.dto.response.ReviewExportResponse;
import com.rongyichuang.review.dto.response.ReviewExportJobStatus;
import com.rongyichuang.review.service.ReviewService;
import com.rongyichuang.review.service.ReviewExportService;
import com.rongyichuang.review.service.ReviewExportJobService;
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.MutationMapping;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.stereotype.Controller;
import java.util.List;
 
/**
 * 评审管理GraphQL解析器
 */
@Controller
public class ReviewResolver {
 
    private static final Logger log = LoggerFactory.getLogger(ReviewResolver.class);
 
    @Autowired
    private ReviewService reviewService;
 
    @Autowired
    private UserContextUtil userContextUtil;
 
    @Autowired
    private ReviewExportService reviewExportService;
 
    @Autowired
    private ReviewExportJobService reviewExportJobService;
 
    /**
     * 查询我未评审的项目列表
     */
    @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);
    }
 
    /**
     * 导出评审ZIP,返回下载链接
     */
    @MutationMapping
    public ReviewExportResponse exportReviewZip(@Argument Long activityId, @Argument List<Long> stageIds) {
        log.info("导出评审ZIP,activityId: {}, stageIds: {}", activityId, stageIds);
        // 权限校验:仅员工(管理员/主办方)可执行导出
        if (!userContextUtil.isCurrentUserEmployee()) {
            log.warn("导出评审ZIP被拒绝,当前用户无员工权限,activityId: {}", activityId);
            return new ReviewExportResponse(false, null, "当前用户无权限导出评审数据");
        }
 
        return reviewExportService.exportReviewZip(activityId, stageIds);
    }
 
    /**
     * 异步导出:启动评审导出任务,返回任务ID
     */
    @MutationMapping
    public String startReviewExportJob(@Argument Long activityId, @Argument List<Long> stageIds) {
        log.info("启动评审导出任务,activityId: {}, stageIds: {}", activityId, stageIds);
        if (!userContextUtil.isCurrentUserEmployee()) {
            log.warn("启动评审导出任务被拒绝,当前用户无员工权限,activityId: {}", activityId);
            return null;
        }
        return reviewExportJobService.startJob(activityId, stageIds);
    }
 
    /**
     * 查询导出任务状态
     */
    @QueryMapping
    public ReviewExportJobStatus getReviewExportJobStatus(@Argument String jobId) {
        return reviewExportJobService.getStatus(jobId);
    }
}