mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 21:41:55 +00:00
codex/fix: uniformity week calculation
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
type Create struct {
|
||||
Date string `form:"date" validate:"required"`
|
||||
ProjectFlockKandangId uint `form:"project_flock_kandang_id" validate:"required,number,min=1"`
|
||||
Week int `form:"week" validate:"required,min=1"`
|
||||
Week int `form:"week" validate:"omitempty,min=1"`
|
||||
}
|
||||
|
||||
type Update struct {
|
||||
@@ -120,14 +120,14 @@ func ParseCreate(c *fiber.Ctx) (*Create, *multipart.FileHeader, error) {
|
||||
return nil, nil, fiber.NewError(fiber.StatusBadRequest, "project_flock_kandang_id is required")
|
||||
}
|
||||
|
||||
week := 0
|
||||
weekStr := strings.TrimSpace(c.FormValue("week"))
|
||||
if weekStr == "" {
|
||||
return nil, nil, fiber.NewError(fiber.StatusBadRequest, "week is required")
|
||||
}
|
||||
|
||||
week, err := strconv.Atoi(weekStr)
|
||||
if err != nil || week <= 0 {
|
||||
return nil, nil, fiber.NewError(fiber.StatusBadRequest, "week is required")
|
||||
if weekStr != "" {
|
||||
parsedWeek, err := strconv.Atoi(weekStr)
|
||||
if err != nil || parsedWeek <= 0 {
|
||||
return nil, nil, fiber.NewError(fiber.StatusBadRequest, "week is invalid")
|
||||
}
|
||||
week = parsedWeek
|
||||
}
|
||||
|
||||
file, err := c.FormFile("document")
|
||||
|
||||
Reference in New Issue
Block a user