Add a Go function for delete_service SQL function

This commit is contained in:
jordi fita mas 2024-01-16 18:12:38 +01:00
parent 6463674c62
commit 36213c75de
2 changed files with 8 additions and 1 deletions

View File

@ -151,6 +151,11 @@ func (c *Conn) OrderServices(ctx context.Context, ids []int) error {
return err return err
} }
func (c *Conn) RemoveService(ctx context.Context, id int) error {
_, err := c.Exec(ctx, "select remove_service($1)", id)
return err
}
func (tx *Tx) AddSurroundingsHighlight(ctx context.Context, companyID int, mediaID int, name string, description string) (int, error) { func (tx *Tx) AddSurroundingsHighlight(ctx context.Context, companyID int, mediaID int, name string, description string) (int, error) {
return tx.GetInt(ctx, "select add_surroundings_highlight($1, $2, $3, $4)", companyID, mediaID, name, description) return tx.GetInt(ctx, "select add_surroundings_highlight($1, $2, $3, $4)", companyID, mediaID, name, description)
} }

View File

@ -245,7 +245,9 @@ func deleteService(w http.ResponseWriter, r *http.Request, user *auth.User, conn
http.Error(w, err.Error(), http.StatusForbidden) http.Error(w, err.Error(), http.StatusForbidden)
return return
} }
conn.MustExec(r.Context(), "select remove_service($1)", id) if err := conn.RemoveService(r.Context(), id); err != nil {
panic(err)
}
httplib.Redirect(w, r, "/admin/services", http.StatusSeeOther) httplib.Redirect(w, r, "/admin/services", http.StatusSeeOther)
} }