fix: added default fields

This commit is contained in:
Marvin Zhang
2024-12-11 20:05:03 +08:00
parent 30767754a0
commit 6b78afe95c
2 changed files with 14 additions and 0 deletions

View File

@@ -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)

View File

@@ -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
}