Paul Pan
26a81652b3
1. add consumer 2. add createVersion 3. add upload 4. fix runner 5. add rejudge Co-authored-by: cxy004 <cxy004@qq.com> Co-authored-by: wzt <w.zhongtao@qq.com>
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package problem
|
|
|
|
import (
|
|
"github.com/WHUPRJ/woj-server/internal/e"
|
|
"github.com/WHUPRJ/woj-server/internal/global"
|
|
"github.com/WHUPRJ/woj-server/internal/model"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type detailsRequest struct {
|
|
Pid uint `form:"pid"`
|
|
}
|
|
|
|
// Details
|
|
// @Summary get details of a problem
|
|
// @Description get details of a problem
|
|
// @Accept application/x-www-form-urlencoded
|
|
// @Produce json
|
|
// @Param pid formData int true "problem id"
|
|
// @Response 200 {object} e.Response "problem details"
|
|
// @Router /v1/problem/details [post]
|
|
func (h *handler) Details(c *gin.Context) {
|
|
req := new(detailsRequest)
|
|
|
|
if err := c.ShouldBind(req); err != nil {
|
|
e.Pong(c, e.InvalidParameter, err.Error())
|
|
return
|
|
}
|
|
|
|
claim, exist := c.Get("claim")
|
|
shouldEnable := !exist || claim.(*global.Claim).Role < model.RoleAdmin
|
|
|
|
p, status := h.problemService.Query(req.Pid, true, shouldEnable)
|
|
if status != e.Success {
|
|
e.Pong(c, status, nil)
|
|
return
|
|
}
|
|
|
|
pv, status := h.problemService.QueryLatestVersion(req.Pid)
|
|
if status != e.Success {
|
|
e.Pong(c, status, nil)
|
|
}
|
|
e.Pong(c, e.Success, gin.H{
|
|
"problem": p,
|
|
"context": pv.Context.Get(),
|
|
})
|
|
}
|