Reorganized the code, moved more things to the new part
This commit is contained in:
47
internal/server/syncHandler.go
Normal file
47
internal/server/syncHandler.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"log"
|
||||
"music-server/internal/backend"
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo"
|
||||
)
|
||||
|
||||
type SyncHandler struct {
|
||||
}
|
||||
|
||||
func NewSyncHandler() *SyncHandler {
|
||||
return &SyncHandler{}
|
||||
}
|
||||
|
||||
func (s *SyncHandler) SyncGames(ctx echo.Context) error {
|
||||
backend.SyncGames()
|
||||
backend.Reset()
|
||||
return ctx.JSON(http.StatusOK, "Games are synced")
|
||||
}
|
||||
|
||||
func (s *SyncHandler) SyncGamesQuick(ctx echo.Context) error {
|
||||
backend.SyncGamesQuick()
|
||||
backend.Reset()
|
||||
return ctx.JSON(http.StatusOK, "Games are synced")
|
||||
}
|
||||
|
||||
func (s *SyncHandler) SyncGamesNewOnlyChanges(ctx echo.Context) error {
|
||||
log.Println("Syncing games new")
|
||||
response := backend.SyncGamesNewOnlyChanges()
|
||||
backend.Reset()
|
||||
return ctx.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
func (s *SyncHandler) SyncGamesNewFull(ctx echo.Context) error {
|
||||
log.Println("Syncing games new full")
|
||||
response := backend.SyncGamesNewFull()
|
||||
backend.Reset()
|
||||
return ctx.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
func (s *SyncHandler) ResetGames(ctx echo.Context) error {
|
||||
backend.ResetDB()
|
||||
return ctx.JSON(http.StatusOK, "Games and songs are deleted from the database")
|
||||
}
|
||||
Reference in New Issue
Block a user