go-tell/internal/persistence/mapping.go

16 lines
728 B
Go
Raw Normal View History

package persistence
import "github.com/example/cms/internal/domain"
func ContentToDomain(m ContentModel) domain.Content {
2026-09-19 15:11:12 +02:00
badges := make([]string, len(m.Badges))
for i := range m.Badges {
badges[i] = m.Badges[i].Name
}
2026-09-19 16:45:24 +02:00
return domain.Content{ID: m.ID, Slug: m.Slug, Title: m.Title, Summary: m.Summary, Body: m.Body, Status: m.Status, Published: m.Published, CategoryID: m.CategoryID, Category: m.Category.Name, Badges: badges, CreatedAt: m.CreatedAt, UpdatedAt: m.UpdatedAt}
}
2026-09-19 16:45:24 +02:00
func ContentFromDomain(d domain.Content) ContentModel {
2026-09-19 16:45:24 +02:00
return ContentModel{ID: d.ID, Slug: d.Slug, Title: d.Title, Summary: d.Summary, Body: d.Body, Status: d.Status, Published: d.Published, CreatedAt: d.CreatedAt, UpdatedAt: d.UpdatedAt}
}