diff --git a/core/controllers/spider.go b/core/controllers/spider.go index e4b9f440..163e6c53 100644 --- a/core/controllers/spider.go +++ b/core/controllers/spider.go @@ -2,6 +2,7 @@ package controllers import ( "errors" + "github.com/crawlab-team/crawlab/core/constants" "github.com/crawlab-team/crawlab/core/models/models" "math" "os" @@ -252,6 +253,13 @@ func PostSpider(c *gin.Context) { return } + if s.Mode == "" { + s.Mode = constants.RunTypeRandom + } + if s.Priority == 0 { + s.Priority = 5 + } + // user u := GetUserFromContext(c) diff --git a/core/controllers/utils_pagination.go b/core/controllers/utils_pagination.go index d16278af..4f148ecf 100644 --- a/core/controllers/utils_pagination.go +++ b/core/controllers/utils_pagination.go @@ -18,6 +18,12 @@ func GetPagination(c *gin.Context) (p *entity.Pagination, err error) { if err := c.ShouldBindQuery(&_p); err != nil { return GetDefaultPagination(), err } + if _p.Page == 0 { + _p.Page = constants.PaginationDefaultPage + } + if _p.Size == 0 { + _p.Size = constants.PaginationDefaultSize + } return &_p, nil }