feat: images

This commit is contained in:
Florian Sylvain
2024-06-13 13:34:10 +02:00
parent eb98a1003e
commit c25fb1b0a3
19 changed files with 387 additions and 100 deletions
+16
View File
@@ -1,6 +1,7 @@
package api
import (
"fmt"
"github.com/go-chi/chi/v5"
"net/http"
"strconv"
@@ -13,6 +14,21 @@ func GetPostDeletePage(w http.ResponseWriter, r *http.Request) {
return
}
localPost, err := Container.GetPostUseCase.GetPost(uint32(id))
if err != nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
}
fmt.Println(localPost.Images)
for _, image := range localPost.Images {
err = Container.DeleteImageUseCase.DeleteImage(image.ID)
if err != nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
}
}
err = Container.DeletePostUseCase.DeletePost(uint32(id))
if err != nil {
http.Error(w, http.StatusText(400), http.StatusBadRequest)