refac: renamed 'post' -> 'article'

This commit is contained in:
Florian Sylvain
2025-11-17 19:27:48 +01:00
parent cb9a431488
commit b470bfcc67
44 changed files with 701 additions and 967 deletions
+42
View File
@@ -0,0 +1,42 @@
package pages
import (
"GoCMS/api"
"GoCMS/api/controllers/article"
"fmt"
"net/http"
"strconv"
"github.com/go-chi/chi/v5"
)
func GetArticleDeletePage(w http.ResponseWriter, r *http.Request) {
id, err := strconv.ParseUint(chi.URLParam(r, "id"), 10, 32)
if err != nil {
http.Error(w, article.IdUint32ErrorMessage, http.StatusBadRequest)
return
}
localArticle, err := api.Container.GetArticleUseCase.GetArticle(uint32(id))
if err != nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
}
fmt.Println(localArticle.Images)
for _, image := range localArticle.Images {
err = api.Container.DeleteImageUseCase.DeleteImage(image.ID)
if err != nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
}
}
err = api.Container.DeleteArticleUseCase.DeleteArticle(uint32(id))
if err != nil {
http.Error(w, http.StatusText(400), http.StatusBadRequest)
return
}
http.Redirect(w, r, "/article", http.StatusSeeOther)
}