add tysc handlers to kontor-gin

This commit is contained in:
2026-09-30 04:12:03 +02:00
parent c848758821
commit f912dcb670
100 changed files with 2420 additions and 1064 deletions
+37
View File
@@ -0,0 +1,37 @@
package repository
import (
"context"
"kontor-api-gin/internal/models"
"log/slog"
"gorm.io/gorm"
)
type TeamRepository struct {
db *gorm.DB
}
func NewTeamRepository(db *gorm.DB) *TeamRepository {
repo := &TeamRepository{db: db}
return repo
}
func (repository *TeamRepository) FindAll(context context.Context) ([]models.Team, error) {
var teams []models.Team
result := repository.db.Find(&teams)
slog.Info("TeamRepository#FindAll", "count", result.RowsAffected)
return teams, nil
}
func (repository *TeamRepository) GetById(context context.Context, id string) (models.Team, error) {
var team = models.Team{ID: id}
slog.Info("TeamRepository#GetById", "id", id)
result := repository.db.First(&team)
if result.Error != nil {
slog.Info("TeamRepository#GetById", "error", result.Error.Error())
}
return team, result.Error
}