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); } }