completed adding MediaLofi for kontor-gin
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s

This commit is contained in:
Thomas Peetz
2026-10-09 18:24:30 +02:00
parent 798c88198c
commit 075695fae6
24 changed files with 471 additions and 178 deletions
+32
View File
@@ -1,7 +1,9 @@
package models
import (
"fmt"
"kontor-api-gin/internal/helpers"
"log/slog"
"time"
)
@@ -30,6 +32,36 @@ type PlayerDTO struct {
LastName string `json:"last_name" binding:"required"`
}
type PlayerDTOList []PlayerDTO
func (playerList *PlayerDTOList) CompareIds(target *PlayerDTOList) (missing, obsolete []string) {
sources := make(map[string]PlayerDTO, len(*playerList))
targets := make(map[string]PlayerDTO, len(*target))
for _, source := range *playerList {
sources[source.ID] = source
}
for _, target := range *target {
targets[target.ID] = target
}
// iterate source IDs
for id := range sources {
if _, ok := targets[id]; ok {
slog.Info(fmt.Sprintf("ID %s found in both lists", id))
} else {
missing = append(missing, id)
}
}
for id := range targets {
if _, ok := sources[id]; ok {
slog.Info(fmt.Sprintf("ID %s found in both lists", id))
} else {
obsolete = append(obsolete, id)
}
}
slog.Info("CompareIds", "missing", missing, "obsolete", obsolete)
return missing, obsolete
}
func ConvertPlayersToDtos(players []Player) []PlayerDTO {
dtos := make([]PlayerDTO, len(players))
for i, player := range players {