feat(tester): add UpdateProblem endpoint

This commit is contained in:
Vyacheslav1557 2025-03-07 15:01:37 +05:00
parent 50a4f87f53
commit 2bc625363d
10 changed files with 237 additions and 34 deletions

View file

@ -1,6 +1,7 @@
package rest
import (
"git.sch9.ru/new_gate/ms-tester/internal/models"
"git.sch9.ru/new_gate/ms-tester/internal/tester"
"git.sch9.ru/new_gate/ms-tester/pkg"
testerv1 "git.sch9.ru/new_gate/ms-tester/proto/tester/v1"
@ -220,6 +221,7 @@ func (h *TesterHandlers) GetProblem(c *fiber.Ctx, id int32) error {
return c.JSON(
testerv1.GetProblemResponse{Problem: testerv1.Problem{
Id: problem.Id,
Title: problem.Title,
Legend: problem.Legend,
InputFormat: problem.InputFormat,
OutputFormat: problem.OutputFormat,
@ -263,3 +265,28 @@ func (h *TesterHandlers) ListParticipants(c *fiber.Ctx, params testerv1.ListPart
return c.JSON(resp)
}
func (h *TesterHandlers) UpdateProblem(c *fiber.Ctx, id int32) error {
var req testerv1.UpdateProblemRequest
err := c.BodyParser(&req)
if err != nil {
return err
}
err = h.problemsUC.UpdateProblem(c.Context(), id, models.ProblemUpdate{
Title: req.Title,
Legend: req.Legend,
InputFormat: req.InputFormat,
OutputFormat: req.OutputFormat,
Notes: req.Notes,
Tutorial: req.Tutorial,
MemoryLimit: req.MemoryLimit,
TimeLimit: req.TimeLimit,
})
if err != nil {
return c.SendStatus(pkg.ToREST(err))
}
return c.SendStatus(fiber.StatusOK)
}