content page

This commit is contained in:
Daniel Noulet 2026-09-19 15:14:16 +02:00
parent 36b2c56987
commit 381ed6270e
8 changed files with 59 additions and 5 deletions

View file

@ -90,6 +90,17 @@ func (r *GORMContentRepository) ListCategories(ctx context.Context) ([]domain.Ca
}
return out, nil
}
func (r *GORMContentRepository) ListBadges(ctx context.Context) ([]domain.Badge, error) {
var rows []persistence.BadgeModel
if err := r.db.WithContext(ctx).Order("name ASC").Find(&rows).Error; err != nil {
return nil, err
}
out := make([]domain.Badge, len(rows))
for i := range rows {
out[i] = domain.Badge{ID: rows[i].ID, Name: rows[i].Name}
}
return out, nil
}
func (r *GORMContentRepository) FindBySlug(ctx context.Context, slug string) (domain.Content, error) {
var row persistence.ContentModel
if err := r.db.WithContext(ctx).Preload("Category").Preload("Badges").Where("slug = ?", slug).First(&row).Error; err != nil {

View file

@ -21,6 +21,7 @@ type ISessionRepository interface {
type IContentRepository interface {
List(context.Context, int, int, string, []string) ([]domain.Content, error)
ListCategories(context.Context) ([]domain.Category, error)
ListBadges(context.Context) ([]domain.Badge, error)
FindBySlug(context.Context, string) (domain.Content, error)
Update(context.Context, domain.Content, domain.ContentHistory) error
}