This commit is contained in:
2026-02-11 17:46:22 +03:00
commit eacfacb13b
266 changed files with 51337 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
package routes
import (
"bssapp-backend/auth"
"bssapp-backend/queries"
"encoding/json"
"net/http"
"github.com/gorilla/mux"
)
// GET /api/statements/{accountCode}/details?startdate=...&enddate=...&parislemler=1&parislemler=2
func GetStatementDetailsHandler(w http.ResponseWriter, r *http.Request) {
claims, ok := auth.GetClaimsFromContext(r.Context())
if !ok || claims == nil {
http.Error(w, "unauthorized", http.StatusUnauthorized)
return
}
vars := mux.Vars(r)
accountCode := vars["accountCode"]
startDate := r.URL.Query().Get("startdate")
endDate := r.URL.Query().Get("enddate")
parislemler := r.URL.Query()["parislemler"]
details, err := queries.GetStatementDetails(accountCode, startDate, endDate, parislemler)
if err != nil {
http.Error(w, "Error fetching statement details: "+err.Error(), http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
if err := json.NewEncoder(w).Encode(details); err != nil {
http.Error(w, "Error encoding response: "+err.Error(), http.StatusInternalServerError)
}
}