From 51aa79e4c26ffc9908c6666adb961a5f1989221a Mon Sep 17 00:00:00 2001 From: SoXX Date: Thu, 27 Jun 2024 22:17:25 +0200 Subject: [PATCH] feat(newAPIs): initial structure for new api endpoints Signed-off-by: SoXX --- pkg/database/database.go | 19 +++++++++-------- pkg/database/postgres.go | 45 ++++++++++++++++++++++++++++++++++++++++ pkg/models/const.go | 6 ++++++ 3 files changed, 61 insertions(+), 9 deletions(-) diff --git a/pkg/database/database.go b/pkg/database/database.go index fc2e5ed..3f739b4 100644 --- a/pkg/database/database.go +++ b/pkg/database/database.go @@ -2,7 +2,6 @@ package database import ( "context" - "git.dragse.it/anthrove/otter-space-sdk/pkg/models" ) @@ -66,14 +65,16 @@ type OtterSpace interface { // GetSourceByDomain retrieves a source by its URL. GetSourceByDomain(ctx context.Context, sourceDomain models.AnthroveSourceDomain) (*models.Source, error) - /* - CreateTagAlias() - DeleteTagAlias() - UpdateTagWithAlias() - CreateTagGroup() - DeleteTagGroup() - UpdateTagWithGroup() + GetAllTagAlias(ctx context.Context) ([]models.TagAlias, error) + GetAllTagAliasByTag(ctx context.Context, tagID models.AnthroveTagID) ([]models.TagAlias, error) + CreateTagAlias(ctx context.Context, tagAliasName models.AnthroveTagAliasName, tagID models.AnthroveTagID) error + DeleteTagAlias(ctx context.Context, tagAliasName models.AnthroveTagAliasName) error - UpdateUserWithScrapeTimeInterval()*/ + GetAllTagGroup(ctx context.Context) ([]models.TagGroup, error) + GetAllTagGroupByTag(ctx context.Context, tagID models.AnthroveTagID) ([]models.TagGroup, error) + CreateTagGroup(ctx context.Context, tagGroupName models.AnthroveTagGroupName, tagID models.AnthroveTagID) + DeleteTagGroup(ctx context.Context, tagGroupName models.AnthroveTagGroupName) error + + UpdateUserWithScrapeTimeInterval(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceID models.AnthroveSourceID, scrapeTime models.AnthroveScrapeTimeInterval) error } diff --git a/pkg/database/postgres.go b/pkg/database/postgres.go index fb53ec9..1770610 100644 --- a/pkg/database/postgres.go +++ b/pkg/database/postgres.go @@ -148,6 +148,51 @@ func (p *postgresqlConnection) GetSourceByDomain(ctx context.Context, sourceDoma return postgres.GetSourceByDomain(ctx, p.db, sourceDomain) } +func (p *postgresqlConnection) GetAllTagAlias(ctx context.Context) ([]models.TagAlias, error) { + //TODO implement me + panic("implement me") +} + +func (p *postgresqlConnection) GetAllTagAliasByTag(ctx context.Context, tagID models.AnthroveTagID) ([]models.TagAlias, error) { + //TODO implement me + panic("implement me") +} + +func (p *postgresqlConnection) CreateTagAlias(ctx context.Context, tagAliasName models.AnthroveTagAliasName, tagID models.AnthroveTagID) error { + //TODO implement me + panic("implement me") +} + +func (p *postgresqlConnection) DeleteTagAlias(ctx context.Context, tagAliasName models.AnthroveTagAliasName) error { + //TODO implement me + panic("implement me") +} + +func (p *postgresqlConnection) GetAllTagGroup(ctx context.Context) ([]models.TagGroup, error) { + //TODO implement me + panic("implement me") +} + +func (p *postgresqlConnection) GetAllTagGroupByTag(ctx context.Context, tagID models.AnthroveTagID) ([]models.TagGroup, error) { + //TODO implement me + panic("implement me") +} + +func (p *postgresqlConnection) CreateTagGroup(ctx context.Context, tagGroupName models.AnthroveTagGroupName, tagID models.AnthroveTagID) { + //TODO implement me + panic("implement me") +} + +func (p *postgresqlConnection) DeleteTagGroup(ctx context.Context, tagGroupName models.AnthroveTagGroupName) error { + //TODO implement me + panic("implement me") +} + +func (p *postgresqlConnection) UpdateUserWithScrapeTimeInterval(ctx context.Context, anthroveUserID models.AnthroveUserID, sourceID models.AnthroveSourceID, scrapeTime models.AnthroveScrapeTimeInterval) error { + //TODO implement me + panic("implement me") +} + func (p *postgresqlConnection) migrateDatabase(dbPool *gorm.DB) error { dialect := "postgres" migrations := &migrate.EmbedFileSystemMigrationSource{FileSystem: embedMigrations, Root: "migrations"} diff --git a/pkg/models/const.go b/pkg/models/const.go index f95434f..13646fe 100644 --- a/pkg/models/const.go +++ b/pkg/models/const.go @@ -1,10 +1,16 @@ package models +import "google.golang.org/genproto/googleapis/type/date" + type AnthroveUserID string type AnthrovePostID string type AnthroveSourceID string type AnthroveSourceDomain string type AnthrovePostURL string +type AnthroveTagGroupName string +type AnthroveTagAliasName string +type AnthroveTagID string +type AnthroveScrapeTimeInterval date.Date type Rating string type TagType string