From 6bccbce91b4a7ef9c357e6cd8e61da8ae92797b8 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Thu, 9 May 2024 19:08:25 -0700 Subject: [PATCH] domain was broken up for external usage --- {internal/domain => domain}/const.go | 0 {internal/domain => domain}/dto.go | 0 {internal/domain => domain}/requests.go | 0 {internal/domain => domain}/responses.go | 0 {internal/domain => domain}/scopes.go | 0 internal/domain/entity.go | 140 ---------------------- internal/{services => dtoconv}/dtoconv.go | 17 +-- 7 files changed, 10 insertions(+), 147 deletions(-) rename {internal/domain => domain}/const.go (100%) rename {internal/domain => domain}/dto.go (100%) rename {internal/domain => domain}/requests.go (100%) rename {internal/domain => domain}/responses.go (100%) rename {internal/domain => domain}/scopes.go (100%) delete mode 100644 internal/domain/entity.go rename internal/{services => dtoconv}/dtoconv.go (65%) diff --git a/internal/domain/const.go b/domain/const.go similarity index 100% rename from internal/domain/const.go rename to domain/const.go diff --git a/internal/domain/dto.go b/domain/dto.go similarity index 100% rename from internal/domain/dto.go rename to domain/dto.go diff --git a/internal/domain/requests.go b/domain/requests.go similarity index 100% rename from internal/domain/requests.go rename to domain/requests.go diff --git a/internal/domain/responses.go b/domain/responses.go similarity index 100% rename from internal/domain/responses.go rename to domain/responses.go diff --git a/internal/domain/scopes.go b/domain/scopes.go similarity index 100% rename from internal/domain/scopes.go rename to domain/scopes.go diff --git a/internal/domain/entity.go b/internal/domain/entity.go deleted file mode 100644 index 6983fb5..0000000 --- a/internal/domain/entity.go +++ /dev/null @@ -1,140 +0,0 @@ -package domain - -import ( - "time" -) - -// This links a source to a discord webhook. -// It is owned by a user so they can remove the link -type AlertDiscordEntity struct { - ID int64 - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt time.Time - UserID int64 - SourceID int64 - DiscordWebHookId int64 -} - -type ArticleEntity struct { - ID int64 - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt time.Time - SourceID int64 - Tags string - Title string - Url string - PubDate time.Time - IsVideo bool - Thumbnail string - Description string - AuthorName string - AuthorImageUrl string -} - -type DiscordQueueEntity struct { - ID int64 - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt time.Time - ArticleId int64 - SourceId int64 -} - -type DiscordWebHookEntity struct { - ID int64 - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt time.Time - UserID int64 - Url string - Server string - Channel string - Enabled bool -} - -type IconEntity struct { - ID int64 - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt time.Time - FileName string - Site string -} - -type SettingEntity struct { - ID int64 - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt time.Time - Key string - Value string - Options string -} - -type SourceEntity struct { - ID int64 - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt time.Time - - // Who will collect from it. Used - // domain.SourceCollector... - Source string - - // Human Readable value to state what is getting collected - DisplayName string - - // Tells the parser where to look for data - Url string - - // Static tags for this defined record - Tags string - - // If the record is disabled, then it will be skipped on processing - Enabled bool -} - -//type SubscriptionEntity struct { -// ID int64 -// CreatedAt time.Time -// UpdatedAt time.Time -// DeletedAt time.Time -// UserID int64 -// SourceID int64 -// //SourceType string -// //SourceName string -// DiscordID int64 -// //DiscordName string -//} - -// This defines what sources a user wants to follow. -// These will show up for the user as a front page -type UserSourceSubscriptionEntity struct { - ID int64 - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt time.Time - UserID int64 - SourceID int64 -} - -type UserEntity struct { - ID int64 - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt time.Time - Username string - Hash string - Scopes string -} - -type RefreshTokenEntity struct { - ID int64 - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt time.Time - Username string - Token string -} diff --git a/internal/services/dtoconv.go b/internal/dtoconv/dtoconv.go similarity index 65% rename from internal/services/dtoconv.go rename to internal/dtoconv/dtoconv.go index 6505dc5..17faa4c 100644 --- a/internal/services/dtoconv.go +++ b/internal/dtoconv/dtoconv.go @@ -1,8 +1,11 @@ package services -import "git.jamestombleson.com/jtom38/newsbot-api/internal/domain" +import ( + "git.jamestombleson.com/jtom38/newsbot-api/domain" + internal "git.jamestombleson.com/jtom38/newsbot-api/internal/domain" +) -func ArticlesToDto(items []domain.ArticleEntity) []domain.ArticleDto { +func ArticlesToDto(items []internal.ArticleEntity) []domain.ArticleDto { var dtos []domain.ArticleDto for _, item := range items { dtos = append(dtos, ArticleToDto(item)) @@ -10,7 +13,7 @@ func ArticlesToDto(items []domain.ArticleEntity) []domain.ArticleDto { return dtos } -func ArticleToDto(item domain.ArticleEntity) domain.ArticleDto { +func ArticleToDto(item internal.ArticleEntity) domain.ArticleDto { return domain.ArticleDto{ ID: item.ID, SourceID: item.SourceID, @@ -26,7 +29,7 @@ func ArticleToDto(item domain.ArticleEntity) domain.ArticleDto { } } -func DiscordWebhooksToDto(items []domain.DiscordWebHookEntity) []domain.DiscordWebHookDto{ +func DiscordWebhooksToDto(items []internal.DiscordWebHookEntity) []domain.DiscordWebHookDto{ var dtos []domain.DiscordWebHookDto for _, item := range items { dtos = append(dtos, DiscordWebhookToDto(item)) @@ -34,7 +37,7 @@ func DiscordWebhooksToDto(items []domain.DiscordWebHookEntity) []domain.DiscordW return dtos } -func DiscordWebhookToDto(item domain.DiscordWebHookEntity) domain.DiscordWebHookDto { +func DiscordWebhookToDto(item internal.DiscordWebHookEntity) domain.DiscordWebHookDto { return domain.DiscordWebHookDto{ ID: item.ID, Server: item.Server, @@ -44,7 +47,7 @@ func DiscordWebhookToDto(item domain.DiscordWebHookEntity) domain.DiscordWebHook } } -func SourcesToDto(items []domain.SourceEntity) []domain.SourceDto { +func SourcesToDto(items []internal.SourceEntity) []domain.SourceDto { var dtos []domain.SourceDto for _, item := range items { dtos = append(dtos, SourceToDto(item)) @@ -52,7 +55,7 @@ func SourcesToDto(items []domain.SourceEntity) []domain.SourceDto { return dtos } -func SourceToDto(item domain.SourceEntity) domain.SourceDto { +func SourceToDto(item internal.SourceEntity) domain.SourceDto { return domain.SourceDto{ ID: item.ID, Source: item.Source,