From 5af3e280b9611f2ad9383cd2d1d3c0923d7a6924 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 23 Jul 2024 18:05:54 +0800 Subject: [PATCH] :bug: Fix validation conditions --- pkg/internal/server/api/articles_api.go | 4 ++-- pkg/internal/server/api/index.go | 2 +- pkg/internal/server/api/stories_api.go | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/internal/server/api/articles_api.go b/pkg/internal/server/api/articles_api.go index 6b9982d..00d874a 100644 --- a/pkg/internal/server/api/articles_api.go +++ b/pkg/internal/server/api/articles_api.go @@ -20,7 +20,7 @@ func createArticle(c *fiber.Ctx) error { var data struct { Title string `json:"title" validate:"required,max=1024"` - Description *string `json:"description" validate:"max=2048"` + Description *string `json:"description"` Content string `json:"content" validate:"required"` Attachments []uint `json:"attachments"` Tags []models.Tag `json:"tags"` @@ -85,7 +85,7 @@ func editArticle(c *fiber.Ctx) error { var data struct { Title string `json:"title" validate:"required,max=1024"` - Description *string `json:"description" validate:"max=2048"` + Description *string `json:"description"` Content string `json:"content" validate:"required"` Attachments []uint `json:"attachments"` Tags []models.Tag `json:"tags"` diff --git a/pkg/internal/server/api/index.go b/pkg/internal/server/api/index.go index 50f2d30..842a9d5 100644 --- a/pkg/internal/server/api/index.go +++ b/pkg/internal/server/api/index.go @@ -24,7 +24,7 @@ func MapAPIs(app *fiber.App, baseURL string) { articles := api.Group("/articles").Name("Article API") { articles.Post("/", createArticle) - articles.Put("/:articleId", editArticle) + articles.Put("/:postId", editArticle) } posts := api.Group("/posts").Name("Posts API") diff --git a/pkg/internal/server/api/stories_api.go b/pkg/internal/server/api/stories_api.go index b38f2e8..4a85378 100644 --- a/pkg/internal/server/api/stories_api.go +++ b/pkg/internal/server/api/stories_api.go @@ -19,9 +19,9 @@ func createStory(c *fiber.Ctx) error { user := c.Locals("user").(models.Account) var data struct { - Title *string `json:"title" validate:"max=1024"` + Title *string `json:"title"` Content string `json:"content" validate:"required,max=4096"` - Location *string `json:"location" validate:"max=2048"` + Location *string `json:"location"` Attachments []uint `json:"attachments"` Tags []models.Tag `json:"tags"` Categories []models.Category `json:"categories"` @@ -103,9 +103,9 @@ func editStory(c *fiber.Ctx) error { user := c.Locals("user").(models.Account) var data struct { - Title *string `json:"title" validate:"max=1024"` + Title *string `json:"title"` Content string `json:"content" validate:"required,max=4096"` - Location *string `json:"location" validate:"max=2048"` + Location *string `json:"location"` Attachments []uint `json:"attachments"` Tags []models.Tag `json:"tags"` Categories []models.Category `json:"categories"`