package dbdto import ( "time" "git.squidspirit.com/squid/blog.git/backend/internal/domain" "github.com/thoas/go-funk" ) type Post struct { ID uint32 Title string Content string Description string PreviewImageURL string Labels []*Label PublishedTime *time.Time CreatedTime time.Time UpdatedTime time.Time } func (p *Post) ToEntity() *domain.Post { return &domain.Post{ ID: p.ID, Title: p.Title, Content: p.Content, Description: p.Description, PreviewImageURL: p.PreviewImageURL, Labels: funk.Map(p.Labels, func(label *Label) *domain.Label { return label.ToEntity() }).([]*domain.Label), PublishedTime: p.PublishedTime, } }