Files
MusicServer/pkg/api/sync.go

48 lines
1014 B
Go

package api
import (
"log"
"music-server/pkg/server"
"net/http"
"github.com/labstack/echo"
)
type Sync struct {
}
func NewSync() *Sync {
return &Sync{}
}
func (s *Sync) SyncGames(ctx echo.Context) error {
server.SyncGames()
server.Reset()
return ctx.JSON(http.StatusOK, "Games are synced")
}
func (s *Sync) SyncGamesQuick(ctx echo.Context) error {
server.SyncGamesQuick()
server.Reset()
return ctx.JSON(http.StatusOK, "Games are synced")
}
func (s *Sync) SyncGamesNewOnlyChanges(ctx echo.Context) error {
log.Println("Syncing games new")
response := server.SyncGamesNewOnlyChanges()
server.Reset()
return ctx.JSON(http.StatusOK, response)
}
func (s *Sync) SyncGamesNewFull(ctx echo.Context) error {
log.Println("Syncing games new full")
response := server.SyncGamesNewFull()
server.Reset()
return ctx.JSON(http.StatusOK, response)
}
func (s *Sync) ResetGames(ctx echo.Context) error {
server.ResetDB()
return ctx.JSON(http.StatusOK, "Games and songs are deleted from the database")
}