woj-server/internal/api/problem/search.go
Paul Pan 26a81652b3 feat: another big update
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>
2022-10-23 17:29:35 +08:00

40 lines
962 B
Go

package problem
import (
"github.com/WHUPRJ/woj-server/internal/e"
"github.com/gin-gonic/gin"
)
type searchRequest struct {
Search string `form:"search"`
}
// Search
// @Summary get detail of a problem
// @Description get detail of a problem
// @Accept application/x-www-form-urlencoded
// @Produce json
// @Param search formData string false "word search"
// @Response 200 {object} e.Response "problemset"
// @Router /v1/problem/search [post]
func (h *handler) Search(c *gin.Context) {
req := new(searchRequest)
if err := c.ShouldBind(req); err != nil {
e.Pong(c, e.InvalidParameter, err.Error())
return
}
// TODO: pagination
if req.Search == "" {
// TODO: query without LIKE
problems, status := h.problemService.QueryFuzz(req.Search, true, true)
e.Pong(c, status, problems)
return
} else {
problems, status := h.problemService.QueryFuzz(req.Search, true, true)
e.Pong(c, status, problems)
return
}
}