feat: add admin routes

This commit is contained in:
2026-07-07 17:21:08 +03:30
parent e58c50d6e5
commit e8396db45c
3 changed files with 495 additions and 1 deletions
+8 -1
View File
@@ -67,6 +67,8 @@ func (h *Handler) Routes(user, pass string) http.Handler {
r.Get("/tournaments", h.tournamentsAdmin)
r.Post("/tournaments/add", h.tournamentAdd)
r.Post("/tournaments/delete", h.tournamentDelete)
// APIِ JSON برای پنلِ Next.js (پشتِ همان Basic Auth).
r.Mount("/api", h.APIRoutes())
return r
}
@@ -661,7 +663,12 @@ func newUUID() string {
}
func (h *Handler) rows(ctx context.Context, query string, cols ...string) []map[string]any {
rs, err := h.db.QueryContext(ctx, query)
return h.rowsArgs(ctx, query, nil, cols...)
}
// rowsArgs مثلِ rows اما با پارامترهای کوئری.
func (h *Handler) rowsArgs(ctx context.Context, query string, args []any, cols ...string) []map[string]any {
rs, err := h.db.QueryContext(ctx, query, args...)
if err != nil {
return nil
}