moved the dto objects back to modles given they are not bound to the database
This commit is contained in:
parent
bb880342e9
commit
4b6008f5e2
@ -1,7 +0,0 @@
|
||||
package models
|
||||
|
||||
type ApiError struct {
|
||||
StatusCode int `json:"status"`
|
||||
Message string `json:"message"`
|
||||
Payload interface{} `json:"payload"`
|
||||
}
|
@ -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
|
Loading…
Reference in New Issue
Block a user