Uploaded Media File Delete Update

This commit is contained in:
2026-02-22 13:04:04 -05:00
parent 3d936d8a6f
commit 3b4d5e4080
16 changed files with 701 additions and 451 deletions

38
server/routes/time.go Normal file
View File

@@ -0,0 +1,38 @@
package routes
import (
"encoding/json"
"log"
"net/http"
)
func (rt *Router) UpdateSimulationTime(w http.ResponseWriter, r *http.Request, idStr string) {
w.Header().Set("Access-Control-Allow-Origin", "*")
var reqBody struct {
SearchTime *float64 `json:"search_time"`
TotalTime *float64 `json:"total_time"`
}
err := json.NewDecoder(r.Body).Decode(&reqBody)
if err != nil {
http.Error(w, "Invalid request body", http.StatusBadRequest)
return
}
defer r.Body.Close()
if reqBody.SearchTime == nil || reqBody.TotalTime == nil {
http.Error(w, "Missing search_time or total_time", http.StatusBadRequest)
return
}
_, err = rt.DB.Exec("UPDATE simulations SET search_time = ?, total_time = ? WHERE id = ?", *reqBody.SearchTime, *reqBody.TotalTime, idStr)
if err != nil {
log.Println("Update simulation error:", err)
http.Error(w, "Failed to update", http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]string{"status": "success"})
}