From 4b6008f5e2f7943fd3c3fa6bfdb5b7058f618465 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Sun, 11 Dec 2022 09:46:14 -0800 Subject: [PATCH] moved the dto objects back to modles given they are not bound to the database --- domain/models/api.go | 7 ------- {database => domain/models}/dto.go | 33 ++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 9 deletions(-) delete mode 100644 domain/models/api.go rename {database => domain/models}/dto.go (51%) diff --git a/domain/models/api.go b/domain/models/api.go deleted file mode 100644 index 02240e8..0000000 --- a/domain/models/api.go +++ /dev/null @@ -1,7 +0,0 @@ -package models - -type ApiError struct { - StatusCode int `json:"status"` - Message string `json:"message"` - Payload interface{} `json:"payload"` -} diff --git a/database/dto.go b/domain/models/dto.go similarity index 51% rename from database/dto.go rename to domain/models/dto.go index 7b4427e..517c08b 100644 --- a/database/dto.go +++ b/domain/models/dto.go @@ -1,9 +1,11 @@ -package database +package models import ( "strings" "github.com/google/uuid" + + "github.com/jtom38/newsbot/collector/database" ) type SourceDto struct { @@ -19,7 +21,7 @@ type SourceDto struct { Deleted bool `json:"deleted"` } -func ConvertToSourceDto(i Source) SourceDto { +func ConvertToSourceDto(i database.Source) SourceDto { var deleted bool if !i.Deleted.Valid { deleted = true @@ -39,6 +41,33 @@ func ConvertToSourceDto(i Source) SourceDto { } } +type DiscordQueueDto struct { + ID uuid.UUID `json:"id"` + Articleid uuid.UUID `json:"articleId"` +} + +func ConvertToDiscordQueueDto(i database.Discordqueue) DiscordQueueDto { + return DiscordQueueDto{ + ID: i.ID, + Articleid: i.Articleid, + } +} + +type SubscriptionDto struct { + ID uuid.UUID `json:"id"` + DiscordWebhookId uuid.UUID `json:"discordwebhookid"` + SourceId uuid.UUID `json:"sourceid"` +} + +func ConvertToSubscriptionDto(i database.Subscription) SubscriptionDto { + c := SubscriptionDto{ + ID: i.ID, + DiscordWebhookId: i.Discordwebhookid, + SourceId: i.Sourceid, + } + return c +} + func splitTags(t string) []string { items := strings.Split(t, ", ") return items