Add, toggle, and delete services
This commit is contained in:
@@ -56,7 +56,7 @@ func ToggleService(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
query := "UPDATE services SET is_active = NOT is_active, updated_at = NOW(), updated_by = $1 WHERE id = $2"
|
||||
result, err := db.DB.Exec(r.Context(), query, serviceID, r.Context().Value(mw.UserIDKey))
|
||||
result, err := db.DB.Exec(r.Context(), query, r.Context().Value(mw.UserIDKey), serviceID)
|
||||
if err != nil {
|
||||
http.Error(w, "Failed to toggle service: "+err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
@@ -184,7 +184,7 @@ func DeleteServiceHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
query := "UPDATE services SET is_active = false, updated_at = NOW() WHERE id = $1"
|
||||
query := "DELETE FROM services WHERE id = $1"
|
||||
result, err := db.DB.Exec(r.Context(), query, serviceID)
|
||||
if err != nil {
|
||||
http.Error(w, "Failed to delete service: "+err.Error(), http.StatusInternalServerError)
|
||||
|
||||
Reference in New Issue
Block a user