fix: check problem version exists before submit (#3)

This commit is contained in:
Paul Pan 2023-12-27 22:28:16 +08:00
parent 297d031e5b
commit 6a72198541
Signed by: Paul
GPG Key ID: D639BDF5BA578AF4

View File

@ -47,6 +47,13 @@ func (h *handler) Create(c *gin.Context) {
return
}
// query latest version
pv, status := h.problemService.QueryLatestVersion(req.Pid)
if status != e.Success {
e.Pong[any](c, status, nil)
return
}
// create submission
createData := &submission.CreateData{
ProblemID: req.Pid,
@ -60,13 +67,6 @@ func (h *handler) Create(c *gin.Context) {
return
}
// query latest version
pv, status := h.problemService.QueryLatestVersion(req.Pid)
if status != e.Success {
e.Pong[any](c, status, nil)
return
}
// submit judge
payload := &model.SubmitJudgePayload{
ProblemVersionID: pv.ID,