feat: add book categorisation in transcripts
This commit is contained in:
@@ -3,6 +3,7 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/prabhupadasays/spsays-bff/internal/repository"
|
||||
@@ -70,6 +71,29 @@ func (h *TranscriptionHandler) GetByType(w http.ResponseWriter, r *http.Request)
|
||||
response.JSON(w, http.StatusOK, docs)
|
||||
}
|
||||
|
||||
func (h *TranscriptionHandler) GetBooks(w http.ResponseWriter, r *http.Request) {
|
||||
docs, err := h.repo.GetBooks(r.Context())
|
||||
if err != nil {
|
||||
response.Error(w, http.StatusInternalServerError, "failed to fetch books")
|
||||
return
|
||||
}
|
||||
response.JSON(w, http.StatusOK, docs)
|
||||
}
|
||||
|
||||
func (h *TranscriptionHandler) GetByBook(w http.ResponseWriter, r *http.Request) {
|
||||
code := strings.ToUpper(chi.URLParam(r, "book"))
|
||||
if h.repo.BookTitle(code) == "" {
|
||||
response.Error(w, http.StatusNotFound, "unknown book")
|
||||
return
|
||||
}
|
||||
docs, err := h.repo.GetByBook(r.Context(), code)
|
||||
if err != nil {
|
||||
response.Error(w, http.StatusInternalServerError, "failed to fetch transcriptions")
|
||||
return
|
||||
}
|
||||
response.JSON(w, http.StatusOK, docs)
|
||||
}
|
||||
|
||||
func (h *TranscriptionHandler) GetYears(w http.ResponseWriter, r *http.Request) {
|
||||
docs, err := h.repo.GetYears(r.Context())
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user