2024-05-09 19:08:43 -07:00
|
|
|
package dtoconv
|
2024-04-28 11:41:11 -07:00
|
|
|
|
2024-05-09 19:08:25 -07:00
|
|
|
import (
|
|
|
|
"git.jamestombleson.com/jtom38/newsbot-api/domain"
|
2024-05-09 19:08:43 -07:00
|
|
|
"git.jamestombleson.com/jtom38/newsbot-api/internal/entity"
|
2024-05-09 19:08:25 -07:00
|
|
|
)
|
2024-04-28 11:41:11 -07:00
|
|
|
|
2024-05-09 19:08:43 -07:00
|
|
|
func ArticlesToDto(items []entity.ArticleEntity) []domain.ArticleDto {
|
2024-04-28 11:41:11 -07:00
|
|
|
var dtos []domain.ArticleDto
|
|
|
|
for _, item := range items {
|
|
|
|
dtos = append(dtos, ArticleToDto(item))
|
|
|
|
}
|
|
|
|
return dtos
|
|
|
|
}
|
|
|
|
|
2024-05-09 19:08:43 -07:00
|
|
|
func ArticleToDto(item entity.ArticleEntity) domain.ArticleDto {
|
2024-04-28 11:41:11 -07:00
|
|
|
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,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-09 19:08:43 -07:00
|
|
|
func DiscordWebhooksToDto(items []entity.DiscordWebHookEntity) []domain.DiscordWebHookDto{
|
2024-04-28 12:32:51 -07:00
|
|
|
var dtos []domain.DiscordWebHookDto
|
|
|
|
for _, item := range items {
|
|
|
|
dtos = append(dtos, DiscordWebhookToDto(item))
|
|
|
|
}
|
|
|
|
return dtos
|
|
|
|
}
|
|
|
|
|
2024-05-09 19:08:43 -07:00
|
|
|
func DiscordWebhookToDto(item entity.DiscordWebHookEntity) domain.DiscordWebHookDto {
|
2024-04-28 12:32:51 -07:00
|
|
|
return domain.DiscordWebHookDto{
|
|
|
|
ID: item.ID,
|
|
|
|
Server: item.Server,
|
|
|
|
Channel: item.Channel,
|
|
|
|
Url: item.Url,
|
|
|
|
Enabled: item.Enabled,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-09 19:08:43 -07:00
|
|
|
func SourcesToDto(items []entity.SourceEntity) []domain.SourceDto {
|
2024-04-28 11:41:11 -07:00
|
|
|
var dtos []domain.SourceDto
|
|
|
|
for _, item := range items {
|
|
|
|
dtos = append(dtos, SourceToDto(item))
|
|
|
|
}
|
|
|
|
return dtos
|
|
|
|
}
|
|
|
|
|
2024-05-09 19:08:43 -07:00
|
|
|
func SourceToDto(item entity.SourceEntity) domain.SourceDto {
|
2024-04-28 11:41:11 -07:00
|
|
|
return domain.SourceDto{
|
|
|
|
ID: item.ID,
|
|
|
|
Source: item.Source,
|
|
|
|
DisplayName: item.DisplayName,
|
|
|
|
Url: item.Url,
|
|
|
|
Tags: item.Tags,
|
|
|
|
Enabled: item.Enabled,
|
|
|
|
}
|
|
|
|
}
|