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