🐛 Fix edit cannot edit tags, categories and attachments
This commit is contained in:
		| @@ -187,6 +187,7 @@ func editPost(c *fiber.Ctx) error { | |||||||
| 		PublishedAt *time.Time          `json:"published_at"` | 		PublishedAt *time.Time          `json:"published_at"` | ||||||
| 		Tags        []models.Tag        `json:"tags"` | 		Tags        []models.Tag        `json:"tags"` | ||||||
| 		Categories  []models.Category   `json:"categories"` | 		Categories  []models.Category   `json:"categories"` | ||||||
|  | 		Attachments []models.Attachment `json:"attachments"` | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if err := BindAndValidate(c, &data); err != nil { | 	if err := BindAndValidate(c, &data); err != nil { | ||||||
| @@ -209,6 +210,7 @@ func editPost(c *fiber.Ctx) error { | |||||||
| 		data.PublishedAt, | 		data.PublishedAt, | ||||||
| 		data.Categories, | 		data.Categories, | ||||||
| 		data.Tags, | 		data.Tags, | ||||||
|  | 		data.Attachments, | ||||||
| 	) | 	) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return fiber.NewError(fiber.StatusBadRequest, err.Error()) | 		return fiber.NewError(fiber.StatusBadRequest, err.Error()) | ||||||
|   | |||||||
| @@ -214,6 +214,7 @@ func EditPost( | |||||||
| 	publishedAt *time.Time, | 	publishedAt *time.Time, | ||||||
| 	categories []models.Category, | 	categories []models.Category, | ||||||
| 	tags []models.Tag, | 	tags []models.Tag, | ||||||
|  | 	attachments []models.Attachment, | ||||||
| ) (models.Post, error) { | ) (models.Post, error) { | ||||||
| 	var err error | 	var err error | ||||||
| 	for idx, category := range categories { | 	for idx, category := range categories { | ||||||
| @@ -237,6 +238,9 @@ func EditPost( | |||||||
| 	post.Title = title | 	post.Title = title | ||||||
| 	post.Content = content | 	post.Content = content | ||||||
| 	post.PublishedAt = *publishedAt | 	post.PublishedAt = *publishedAt | ||||||
|  | 	post.Tags = tags | ||||||
|  | 	post.Categories = categories | ||||||
|  | 	post.Attachments = attachments | ||||||
|  |  | ||||||
| 	err = database.C.Save(&post).Error | 	err = database.C.Save(&post).Error | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user