fix: check problem version exists on update when IsEnabled = true (#3)
This commit is contained in:
parent
6a72198541
commit
cc2c42bded
@ -84,6 +84,16 @@ func (h *handler) Update(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if IsEnabled is set to true, check if the problem has a latest version
|
||||||
|
if req.IsEnabled {
|
||||||
|
_, status := h.problemService.QueryLatestVersion(p.ID)
|
||||||
|
if status != e.Success {
|
||||||
|
e.Pong[any](c, status, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
p.IsEnabled = true
|
||||||
|
}
|
||||||
|
|
||||||
// update problem
|
// update problem
|
||||||
p.Title = utils.If(req.Title != "", req.Title, p.Title)
|
p.Title = utils.If(req.Title != "", req.Title, p.Title)
|
||||||
p.Statement = utils.If(req.Statement != "", req.Statement, p.Statement)
|
p.Statement = utils.If(req.Statement != "", req.Statement, p.Statement)
|
||||||
@ -92,7 +102,6 @@ func (h *handler) Update(c *gin.Context) {
|
|||||||
_ = tags.Set(req.Tags)
|
_ = tags.Set(req.Tags)
|
||||||
p.Tags = tags
|
p.Tags = tags
|
||||||
}
|
}
|
||||||
p.IsEnabled = req.IsEnabled
|
|
||||||
|
|
||||||
p, status = h.problemService.Update(p)
|
p, status = h.problemService.Update(p)
|
||||||
e.Pong(c, status, p)
|
e.Pong(c, status, p)
|
||||||
|
Loading…
Reference in New Issue
Block a user