mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-03 18:22:57 +00:00
dev day #69
This commit is contained in:
@@ -27,7 +27,7 @@ func NewArticleController(db *gorm.DB) *ArticleController {
|
||||
// CreateArticleRequest represents the request body for creating an article
|
||||
type CreateArticleRequest struct {
|
||||
Title string `json:"title" binding:"required"`
|
||||
Content string `json:"content" binding:"required"`
|
||||
Content string `json:"content"`
|
||||
CategoryID *uint `json:"category_id"`
|
||||
CategoryName string `json:"category_name"`
|
||||
ImageURL string `json:"image_url"`
|
||||
@@ -138,6 +138,10 @@ func (ac *ArticleController) CreateArticle(c *gin.Context) {
|
||||
if req.Published != nil {
|
||||
published = *req.Published
|
||||
}
|
||||
if published && strings.TrimSpace(req.Content) == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Obsah je povinný pro publikovaný článek"})
|
||||
return
|
||||
}
|
||||
var publishedAt *time.Time
|
||||
if req.PublishedAt != nil && strings.TrimSpace(*req.PublishedAt) != "" {
|
||||
if t, err := time.Parse(time.RFC3339, *req.PublishedAt); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user