2026-09-19 14:17:27 +02:00
|
|
|
package persistence
|
|
|
|
|
|
|
|
|
|
import "github.com/example/cms/internal/domain"
|
|
|
|
|
|
2026-09-19 14:56:49 +02:00
|
|
|
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 14:56:49 +02:00
|
|
|
}
|
2026-09-19 16:45:24 +02:00
|
|
|
|
2026-09-19 14:56:49 +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}
|
2026-09-19 14:17:27 +02:00
|
|
|
}
|