fix: resolve compilation errors in frontend and backend
This commit is contained in:
@@ -3,10 +3,10 @@ package admin
|
||||
import (
|
||||
"crussell/db"
|
||||
"crussell/internal/validators"
|
||||
"crussell/mw"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
@@ -117,38 +117,38 @@ func UpdatePatchTest(w http.ResponseWriter, r *http.Request) {
|
||||
i := 1
|
||||
|
||||
if req.Name != nil {
|
||||
query += "name = $" + string(rune('0'+i)) + ", "
|
||||
query += "name = $" + strconv.Itoa(i) + ", "
|
||||
args = append(args, *req.Name)
|
||||
i++
|
||||
}
|
||||
if req.Description != nil {
|
||||
query += "description = $" + string(rune('0'+i)) + ", "
|
||||
query += "description = $" + strconv.Itoa(i) + ", "
|
||||
args = append(args, *req.Description)
|
||||
i++
|
||||
}
|
||||
if req.NoticeDurationHours != nil {
|
||||
query += "notice_duration_hours = $" + string(rune('0'+i)) + ", "
|
||||
query += "notice_duration_hours = $" + strconv.Itoa(i) + ", "
|
||||
args = append(args, *req.NoticeDurationHours)
|
||||
i++
|
||||
}
|
||||
if req.ExpiryMonths != nil {
|
||||
query += "expiry_months = $" + string(rune('0'+i)) + ", "
|
||||
query += "expiry_months = $" + strconv.Itoa(i) + ", "
|
||||
args = append(args, *req.ExpiryMonths)
|
||||
i++
|
||||
}
|
||||
if req.ServiceIDs != nil {
|
||||
query += "service_ids = $" + string(rune('0'+i)) + ", "
|
||||
query += "service_ids = $" + strconv.Itoa(i) + ", "
|
||||
args = append(args, req.ServiceIDs)
|
||||
i++
|
||||
}
|
||||
|
||||
query = query[:len(query)-2]
|
||||
query += " WHERE id = $" + string(rune('0'+i))
|
||||
query += " WHERE id = $" + strconv.Itoa(i)
|
||||
args = append(args, id)
|
||||
|
||||
_, err := db.DB.Exec(r.Context(), query, args...)
|
||||
if err != nil {
|
||||
http.Error(w, "Failed to update patch test: "+err.Error(), http.StatusInternalServerError)
|
||||
http.Error(w, "Failed to update patch test: " + err.Error() + " Query: " + query, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user