/
setwind
/
olympiad
Обзор
Документация
Войти
/
setwind
/
olympiad
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/main/java/com/cfuv/olympus/controller/JudgeController.java
104 строки
5 KB
setwind
test and groups view
05 май 2025, 15:35
05 май 2025, 15:35
8e680ac
Код
Авторство
О чём код?
package com.cfuv.olympus.controller; import com.cfuv.olympus.entity.domain.contest.Contest; import com.cfuv.olympus.entity.domain.contest.Folder; import com.cfuv.olympus.entity.dto.contest.get.TestResult; import com.cfuv.olympus.entity.dto.contest.table.JudgeTableResponse; import com.cfuv.olympus.entity.dto.contest.table.ResultTableResponse; import com.cfuv.olympus.entity.dto.task.feedback.FeedbackRequest; import com.cfuv.olympus.service.ContestService; import com.cfuv.olympus.service.TaskService; import com.cfuv.olympus.service.TestService; import com.cfuv.olympus.service.UserTaskService; import com.cfuv.olympus.web.security.UserSession; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import jakarta.validation.constraints.Min; import lombok.RequiredArgsConstructor; import org.springdoc.api.ErrorMessage; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; @Tag(name = "Judge controller", description = "Judge management ") @RestController @RequestMapping("/api/v1/judge") @RequiredArgsConstructor @Validated public class JudgeController { private final TaskService taskService; private final UserTaskService userTaskService; private final ContestService contestService; private final TestService testService; //@CheckContestState @Operation(summary = "Get contest by id", description = "Return contest by id") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "404", description = "Bad request - Contest does not exists", content = @Content(schema = @Schema(implementation = ErrorMessage.class))) }) @GetMapping("/contest") public Contest getContestByJudge(@AuthenticationPrincipal UserSession judge) { return contestService.getContestById(judge.getContestId()); } //Judge //@CheckContestState @Operation(summary = "Get contest user tasks table", description = "Returns a contest user tasks table for judge") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved") }) @GetMapping("/contest/table") public List<JudgeTableResponse> getContestTableByJudge(@AuthenticationPrincipal UserSession user) { return taskService.getJudgeTableByContestId(user.getContestId(), user.getId()); } @GetMapping("/contest/user-problems/files") public Folder getUserAnswerById(@RequestParam @Min(value = 0, message = "Id cannot be less than 0") Long id, @AuthenticationPrincipal UserSession user) { return userTaskService.getFileStructure(id); } @Operation(summary = "Get user answer", description = "Returns meta data about user answer") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved") }) @GetMapping("/contest/user-problems/tests") public TestResult getTestResult(@RequestParam @Min(value = 0, message = "Id cannot be less than 0") Long id, @AuthenticationPrincipal UserSession user) { return testService.getResult(id); } //@CheckContestState @Operation(summary = "Send feedback", description = "Send feedback from judge to participant problem") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "404", description = "Not found - User task not found", content = @Content(schema = @Schema(implementation = ErrorMessage.class))) }) @PostMapping("/feedback") public void feedback(@Valid @RequestBody FeedbackRequest feedbackRequest, @AuthenticationPrincipal UserSession user) { userTaskService.feedback(feedbackRequest, user); } @Operation(summary = "Get contest user tasks table", description = "Returns a contest user tasks table for judge") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved") }) @PostMapping("/contest/user-problems/result") public ResultTableResponse getContestResultTableByJudge(@AuthenticationPrincipal UserSession user) { return taskService.getResultTableResponseNotAdmin(user.getContestId()); } }