features/repo-updates #4
46
internal/services/dtoconv.go
Normal file
46
internal/services/dtoconv.go
Normal file
@ -0,0 +1,46 @@
|
||||
package services
|
||||
|
||||
import "git.jamestombleson.com/jtom38/newsbot-api/internal/domain"
|
||||
|
||||
func ArticlesToDto(items []domain.ArticleEntity) []domain.ArticleDto {
|
||||
var dtos []domain.ArticleDto
|
||||
for _, item := range items {
|
||||
dtos = append(dtos, ArticleToDto(item))
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
func ArticleToDto(item domain.ArticleEntity) domain.ArticleDto {
|
||||
return domain.ArticleDto{
|
||||
ID: item.ID,
|
||||
SourceID: item.SourceID,
|
||||
Tags: item.Tags,
|
||||
Title: item.Title,
|
||||
Url: item.Url,
|
||||
PubDate: item.PubDate,
|
||||
IsVideo: item.IsVideo,
|
||||
Thumbnail: item.Thumbnail,
|
||||
Description: item.Description,
|
||||
AuthorName: item.AuthorName,
|
||||
AuthorImageUrl: item.AuthorImageUrl,
|
||||
}
|
||||
}
|
||||
|
||||
func SourcesToDto(items []domain.SourceEntity) []domain.SourceDto {
|
||||
var dtos []domain.SourceDto
|
||||
for _, item := range items {
|
||||
dtos = append(dtos, SourceToDto(item))
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
func SourceToDto(item domain.SourceEntity) domain.SourceDto {
|
||||
return domain.SourceDto{
|
||||
ID: item.ID,
|
||||
Source: item.Source,
|
||||
DisplayName: item.DisplayName,
|
||||
Url: item.Url,
|
||||
Tags: item.Tags,
|
||||
Enabled: item.Enabled,
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user