Compare commits

..

No commits in common. "9fe2d0edc38239c3d59fd6c5819bee005cfc406b" and "1dc9b1fb7c8e49eaaacfcbab239116ac8df4b139" have entirely different histories.

10 changed files with 75 additions and 694 deletions

View File

@ -1,127 +0,0 @@
package database
import (
"context"
"errors"
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/error"
"git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/models"
"gorm.io/gorm"
)
func CreatePost(ctx context.Context, post models.Post) (models.Post, error) {
if client == nil {
return models.Post{}, &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
result := client.WithContext(ctx).Create(&post)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return models.Post{}, &otterError.Database{Reason: otterError.DuplicateKey}
}
return models.Post{}, result.Error
}
return post, nil
}
func CreatePostInBatch(ctx context.Context, post []models.Post, batchSize int) error {
if client == nil {
return &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if post == nil {
return &otterError.EntityValidationFailed{Reason: otterError.PostListIsEmpty}
}
if len(post) == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.PostListIsEmpty}
}
if batchSize == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.BatchSizeIsEmpty}
}
result := client.WithContext(ctx).CreateInBatches(&post, batchSize)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return &otterError.Database{Reason: otterError.DuplicateKey}
}
return result.Error
}
return nil
}
func GetPostByID(ctx context.Context, id models.PostID) (models.Post, error) {
var post models.Post
if client == nil {
return models.Post{}, &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if len(id) == 0 {
return models.Post{}, &otterError.EntityValidationFailed{Reason: otterError.PostIDIsEmpty}
}
result := client.WithContext(ctx).First(&post, "id = ?", id)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return models.Post{}, &otterError.Database{Reason: otterError.NoDataFound}
}
return models.Post{}, result.Error
}
return post, nil
}
func UpdatePost(ctx context.Context, anthrovePost models.Post) error {
if client == nil {
return &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if len(anthrovePost.ID) == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.PostIDIsEmpty}
}
updatePost := models.Post{
Rating: anthrovePost.Rating,
Tags: anthrovePost.Tags,
References: anthrovePost.References,
}
result := client.WithContext(ctx).Model(&updatePost).Update("deleted_at", gorm.DeletedAt{})
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return &otterError.Database{Reason: otterError.NoDataFound}
}
return result.Error
}
return nil
}
func DeletePost(ctx context.Context, id models.PostID) error {
var userFavorite models.UserFavorite
if client == nil {
return &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if len(id) == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.PostIDIsEmpty}
}
if len(id) != 25 {
return &otterError.EntityValidationFailed{Reason: otterError.PostIDToShort}
}
result := client.WithContext(ctx).Delete(&userFavorite, "id = ?", id)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return &otterError.Database{Reason: otterError.NoDataFound}
}
return result.Error
}
return nil
}

View File

@ -8,40 +8,43 @@ import (
"gorm.io/gorm" "gorm.io/gorm"
) )
func CreateSource(ctx context.Context, source models.Source) (models.Source, error) { func CreateUserSource(ctx context.Context, userSource models.UserSource) (models.UserSource, error) {
if client == nil { if client == nil {
return models.Source{}, &otterError.Database{Reason: otterError.DatabaseIsNotConnected} return models.UserSource{}, &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
} }
result := client.WithContext(ctx).Create(&source) result := client.WithContext(ctx).Create(&userSource)
if result.Error != nil { if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) { if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return models.Source{}, &otterError.Database{Reason: otterError.DuplicateKey} return models.UserSource{}, &otterError.Database{Reason: otterError.DuplicateKey}
} }
return models.Source{}, result.Error return models.UserSource{}, result.Error
} }
return source, nil return userSource, nil
} }
func CreateSourceInBatch(ctx context.Context, source []models.Source, batchSize int) error { func UpdateUserSource(ctx context.Context, userSource models.UserSource) error {
if client == nil { if client == nil {
return &otterError.Database{Reason: otterError.DatabaseIsNotConnected} return &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
} }
if source == nil { if len(userSource.ID) == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.SourceListIsEmpty} return &otterError.EntityValidationFailed{Reason: otterError.UserSourceIDEmpty}
} }
if len(source) == 0 { updatedUserSource := models.UserSource{
return &otterError.EntityValidationFailed{Reason: otterError.SourceListIsEmpty} BaseModel: models.BaseModel[models.UserSourceID]{
ID: userSource.ID,
},
ScrapeTimeInterval: userSource.ScrapeTimeInterval,
AccountUsername: userSource.AccountUsername,
AccountID: userSource.AccountID,
LastScrapeTime: userSource.LastScrapeTime,
AccountValidate: userSource.AccountValidate,
} }
if batchSize == 0 { result := client.WithContext(ctx).Updates(&updatedUserSource)
return &otterError.EntityValidationFailed{Reason: otterError.BatchSizeIsEmpty}
}
result := client.WithContext(ctx).CreateInBatches(&source, batchSize)
if result.Error != nil { if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) { if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return &otterError.Database{Reason: otterError.DuplicateKey} return &otterError.Database{Reason: otterError.DuplicateKey}
@ -52,96 +55,48 @@ func CreateSourceInBatch(ctx context.Context, source []models.Source, batchSize
return nil return nil
} }
func UpdateSource(ctx context.Context, source models.Source) error { func GetUserSourceByID(ctx context.Context, id models.UserSourceID) (models.UserSource, error) {
var user models.UserSource
if client == nil {
return models.UserSource{}, &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if len(id) == 0 {
return models.UserSource{}, &otterError.EntityValidationFailed{Reason: otterError.UserSourceIDEmpty}
}
if len(id) != 25 {
return models.UserSource{}, &otterError.EntityValidationFailed{Reason: otterError.UserSourceIDToShort}
}
result := client.WithContext(ctx).First(&user, "id = ?", id)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return models.UserSource{}, &otterError.Database{Reason: otterError.NoDataFound}
}
return models.UserSource{}, result.Error
}
return user, nil
}
func DeleteUserSource(ctx context.Context, id models.UserSourceID) error {
var user models.UserSource
if client == nil { if client == nil {
return &otterError.Database{Reason: otterError.DatabaseIsNotConnected} return &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
} }
if len(source.ID) == 0 { if len(id) == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.SourceIDIsEmpty} return &otterError.EntityValidationFailed{Reason: otterError.UserSourceIDEmpty}
} }
updateSource := models.Source{ if len(id) != 25 {
DisplayName: source.DisplayName, return &otterError.EntityValidationFailed{Reason: otterError.UserSourceIDToShort}
Domain: source.Domain,
Icon: source.Icon,
} }
result := client.WithContext(ctx).Model(&updateSource).Update("deleted_at", gorm.DeletedAt{}) result := client.WithContext(ctx).Delete(&user, id)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return &otterError.Database{Reason: otterError.NoDataFound}
}
return result.Error
}
return nil
}
func GetSourceByID(ctx context.Context, id models.SourceID) (models.Source, error) {
var source models.Source
if client == nil {
return models.Source{}, &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if len(id) == 0 {
return models.Source{}, &otterError.EntityValidationFailed{Reason: otterError.SourceIDIsEmpty}
}
if len(id) != 25 {
return models.Source{}, &otterError.EntityValidationFailed{Reason: otterError.SourceIDToShort}
}
result := client.WithContext(ctx).First(&source, "id = ?", id)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return models.Source{}, &otterError.Database{Reason: otterError.NoDataFound}
}
return models.Source{}, result.Error
}
return source, nil
}
func GetSourceByDomain(ctx context.Context, sourceDomain models.SourceDomain) (models.Source, error) {
var source models.Source
if client == nil {
return models.Source{}, &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if len(sourceDomain) == 0 {
return models.Source{}, &otterError.EntityValidationFailed{Reason: otterError.SourceDomainIsEmpty}
}
result := client.WithContext(ctx).First(&source, "domain = ?", sourceDomain)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return models.Source{}, &otterError.Database{Reason: otterError.NoDataFound}
}
return models.Source{}, result.Error
}
return source, nil
}
func DeleteSource(ctx context.Context, id models.SourceID) error {
var source models.Source
if client == nil {
return &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if len(id) == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.SourceIDIsEmpty}
}
if len(id) != 25 {
return &otterError.EntityValidationFailed{Reason: otterError.SourceIDToShort}
}
result := client.WithContext(ctx).Delete(&source, id)
if result.Error != nil { if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) { if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return &otterError.Database{Reason: otterError.NoDataFound} return &otterError.Database{Reason: otterError.NoDataFound}

View File

@ -1,81 +0,0 @@
package database
import (
"context"
"errors"
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/error"
"git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/models"
"gorm.io/gorm"
)
func CreateTag(ctx context.Context, tagName models.TagName, tagType models.TagType) (models.Tag, error) {
if client == nil {
return models.Tag{}, &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
tag := models.Tag{
Name: tagName,
Type: tagType,
}
result := client.WithContext(ctx).Create(&tag)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return models.Tag{}, &otterError.Database{Reason: otterError.DuplicateKey}
}
return models.Tag{}, result.Error
}
return tag, nil
}
func CreateTagInBatch(ctx context.Context, tags []models.Tag, batchSize int) error {
if client == nil {
return &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if tags == nil {
return &otterError.EntityValidationFailed{Reason: otterError.TagListIsEmpty}
}
if len(tags) == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.TagListIsEmpty}
}
if batchSize == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.BatchSizeIsEmpty}
}
result := client.WithContext(ctx).CreateInBatches(&tags, batchSize)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return &otterError.Database{Reason: otterError.DuplicateKey}
}
return result.Error
}
return nil
}
func DeleteTag(ctx context.Context, tagName models.TagName) error {
var tag models.Tag
if client == nil {
return &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if len(tagName) == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.TagNameIsEmpty}
}
result := client.WithContext(ctx).Delete(&tag, tagName)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return &otterError.Database{Reason: otterError.NoDataFound}
}
return result.Error
}
return nil
}

View File

@ -1,80 +0,0 @@
package database
import (
"context"
"errors"
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/error"
"git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/models"
"gorm.io/gorm"
)
func CreateTagAlias(ctx context.Context, tagAliasName models.TagAliasName, tagName models.TagName) (models.TagAlias, error) {
if client == nil {
return models.TagAlias{}, &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
tagAlias := models.TagAlias{
Name: tagAliasName,
TagID: tagName,
}
result := client.WithContext(ctx).Create(&tagAlias)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return models.TagAlias{}, &otterError.Database{Reason: otterError.DuplicateKey}
}
return models.TagAlias{}, result.Error
}
return tagAlias, nil
}
func CreateTagAliasInBatch(ctx context.Context, tagsAliases []models.TagAlias, batchSize int) error {
if client == nil {
return &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if tagsAliases == nil {
return &otterError.EntityValidationFailed{Reason: otterError.TagAliasListIsEmpty}
}
if len(tagsAliases) == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.TagAliasListIsEmpty}
}
if batchSize == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.BatchSizeIsEmpty}
}
result := client.WithContext(ctx).CreateInBatches(&tagsAliases, batchSize)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return &otterError.Database{Reason: otterError.DuplicateKey}
}
return result.Error
}
return nil
}
func DeleteTagAlias(ctx context.Context, tagAliasName models.TagAliasName) error {
var tagAlias models.TagAlias
if client == nil {
return &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if len(tagAliasName) == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.TagAliasNameIsEmpty}
}
result := client.WithContext(ctx).Delete(&tagAlias, tagAliasName)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return &otterError.Database{Reason: otterError.NoDataFound}
}
return result.Error
}
return nil
}

View File

@ -1,80 +0,0 @@
package database
import (
"context"
"errors"
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/error"
"git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/models"
"gorm.io/gorm"
)
func CreateTagGroup(ctx context.Context, tagGroupName models.TagGroupName, tagName models.TagName) (models.TagGroup, error) {
if client == nil {
return models.TagGroup{}, &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
tagGroup := models.TagGroup{
Name: tagGroupName,
TagID: tagName,
}
result := client.WithContext(ctx).Create(&tagGroup)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return models.TagGroup{}, &otterError.Database{Reason: otterError.DuplicateKey}
}
return models.TagGroup{}, result.Error
}
return tagGroup, nil
}
func CreateTagGroupInBatch(ctx context.Context, tagsGroups []models.TagGroup, batchSize int) error {
if client == nil {
return &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if tagsGroups == nil {
return &otterError.EntityValidationFailed{Reason: otterError.TagGroupListIsEmpty}
}
if len(tagsGroups) == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.TagGroupListIsEmpty}
}
if batchSize == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.BatchSizeIsEmpty}
}
result := client.WithContext(ctx).CreateInBatches(&tagsGroups, batchSize)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return &otterError.Database{Reason: otterError.DuplicateKey}
}
return result.Error
}
return nil
}
func DeleteTagGroup(ctx context.Context, tagGroupName models.TagGroupName) error {
var tagGroup models.TagGroup
if client == nil {
return &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if len(tagGroupName) == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.TagGroupNameIsEmpty}
}
result := client.WithContext(ctx).Delete(&tagGroup, tagGroupName)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return &otterError.Database{Reason: otterError.NoDataFound}
}
return result.Error
}
return nil
}

View File

@ -1,79 +0,0 @@
package database
import (
"context"
"errors"
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/error"
"git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/models"
"gorm.io/gorm"
)
func CreateUser(ctx context.Context, id models.UserID) (models.User, error) {
if client == nil {
return models.User{}, &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
user := models.User{
BaseModel: models.BaseModel[models.UserID]{
ID: id,
},
}
result := client.WithContext(ctx).Create(&user)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return models.User{}, &otterError.Database{Reason: otterError.DuplicateKey}
}
return models.User{}, result.Error
}
return user, nil
}
func GetUserByID(ctx context.Context, id models.UserID) (models.User, error) {
var user models.User
if client == nil {
return models.User{}, &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if len(id) == 0 {
return models.User{}, &otterError.EntityValidationFailed{Reason: otterError.UserIDIsEmpty}
}
if len(id) != 25 {
return models.User{}, &otterError.EntityValidationFailed{Reason: otterError.UserIDToShort}
}
result := client.WithContext(ctx).First(&user, "id = ?", id)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return models.User{}, &otterError.Database{Reason: otterError.NoDataFound}
}
return models.User{}, result.Error
}
return user, nil
}
func DeleteUser(ctx context.Context, id models.UserID) error {
var user models.User
if client == nil {
return &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if len(id) == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.UserIDIsEmpty}
}
result := client.WithContext(ctx).Delete(&user, id)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return &otterError.Database{Reason: otterError.NoDataFound}
}
return result.Error
}
return nil
}

View File

@ -1,108 +0,0 @@
package database
import (
"context"
"errors"
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/error"
"git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/models"
"gorm.io/gorm"
)
func CreateUserSource(ctx context.Context, userSource models.UserSource) (models.UserSource, error) {
if client == nil {
return models.UserSource{}, &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
result := client.WithContext(ctx).Create(&userSource)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return models.UserSource{}, &otterError.Database{Reason: otterError.DuplicateKey}
}
return models.UserSource{}, result.Error
}
return userSource, nil
}
func UpdateUserSource(ctx context.Context, userSource models.UserSource) error {
if client == nil {
return &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if len(userSource.ID) == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.UserSourceIDIsEmpty}
}
updatedUserSource := models.UserSource{
BaseModel: models.BaseModel[models.UserSourceID]{
ID: userSource.ID,
},
ScrapeTimeInterval: userSource.ScrapeTimeInterval,
AccountUsername: userSource.AccountUsername,
AccountID: userSource.AccountID,
LastScrapeTime: userSource.LastScrapeTime,
AccountValidate: userSource.AccountValidate,
}
result := client.WithContext(ctx).Updates(&updatedUserSource)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
return &otterError.Database{Reason: otterError.DuplicateKey}
}
return result.Error
}
return nil
}
func GetUserSourceByID(ctx context.Context, id models.UserSourceID) (models.UserSource, error) {
var user models.UserSource
if client == nil {
return models.UserSource{}, &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if len(id) == 0 {
return models.UserSource{}, &otterError.EntityValidationFailed{Reason: otterError.UserSourceIDIsEmpty}
}
if len(id) != 25 {
return models.UserSource{}, &otterError.EntityValidationFailed{Reason: otterError.UserSourceIDToShort}
}
result := client.WithContext(ctx).First(&user, "id = ?", id)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return models.UserSource{}, &otterError.Database{Reason: otterError.NoDataFound}
}
return models.UserSource{}, result.Error
}
return user, nil
}
func DeleteUserSource(ctx context.Context, id models.UserSourceID) error {
var user models.UserSource
if client == nil {
return &otterError.Database{Reason: otterError.DatabaseIsNotConnected}
}
if len(id) == 0 {
return &otterError.EntityValidationFailed{Reason: otterError.UserSourceIDIsEmpty}
}
if len(id) != 25 {
return &otterError.EntityValidationFailed{Reason: otterError.UserSourceIDToShort}
}
result := client.WithContext(ctx).Delete(&user, id)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return &otterError.Database{Reason: otterError.NoDataFound}
}
return result.Error
}
return nil
}

View File

@ -3,33 +3,16 @@ package error
import "fmt" import "fmt"
const ( const (
UserIDIsEmpty = "postID cannot be empty" UserIDIsEmpty = "PostID cannot be empty"
UserIDToShort = "postID needs to be 25 characters long" UserIDToShort = "PostID needs to be 25 characters long"
SourceIDEmpty = "SourceID cannot be empty"
SourceListIsEmpty = "sourceList cannot be empty" SourceIDToShort = "SourceID needs to be 25 characters long"
SourceIDIsEmpty = "SourceID cannot be empty" UserSourceIDEmpty = "UserSourceID cannot be empty"
SourceIDToShort = "sourceID needs to be 25 characters long" UserSourceIDToShort = "UserSourceID needs to be 25 characters long"
SourceDomainIsEmpty = "source Domain cannot be empty" TagIDEmpty = "tagID cannot be empty"
UserSourceIDIsEmpty = "userSourceID cannot be empty"
UserSourceIDToShort = "userSourceID needs to be 25 characters long"
TagListIsEmpty = "tagList cannot be empty"
TagNameIsEmpty = "tagName cannot be empty"
TagAliasListIsEmpty = "tagAliasList cannot be empty"
TagAliasNameIsEmpty = "tagAliasName cannot be empty"
TagGroupListIsEmpty = "tagGroupList cannot be empty"
TagGroupNameIsEmpty = "tagGroupName cannot be empty"
UserFavoriteListIsEmpty = "userFavoriteList cannot be empty" UserFavoriteListIsEmpty = "userFavoriteList cannot be empty"
UserFavoriteIDIsEmpty = "userFavoriteID cannot be empty" UserFavoriteIDIsEmpty = "userFavoriteID cannot be empty"
UserFavoriteIDToShort = "userFavoriteID needs to be 25 characters long" UserFavoriteIDToShort = "UserFavoriteID needs to be 25 characters long"
PostListIsEmpty = "userFavoriteList cannot be empty"
PostIDIsEmpty = "userFavoriteID cannot be empty"
PostIDToShort = "PostID needs to be 25 characters long"
BatchSizeIsEmpty = "batchSize cannot be empty" BatchSizeIsEmpty = "batchSize cannot be empty"
) )

View File

@ -5,17 +5,15 @@ import "time"
type ( type (
UserID string UserID string
PostID string PostID string
PostURL string
SourceID string SourceID string
SourceDomain string SourceDomain string
PostURL string
TagName string
TagGroupName string TagGroupName string
TagAliasName string TagAliasName string
TagID string
ScrapeTimeInterval int ScrapeTimeInterval int
UserLastScrapeTime time.Time UserLastScrapeTime time.Time
TagName string
Rating string Rating string
TagType string TagType string

View File

@ -2,7 +2,7 @@ package models
// Tag models // Tag models
type Tag struct { type Tag struct {
Name TagName `json:"name" gorm:"primaryKey"` Name string `json:"name" gorm:"primaryKey"`
Type TagType `json:"type" gorm:"column:tag_type"` Type TagType `json:"type" gorm:"column:tag_type"`
Aliases []TagAlias `json:"aliases" gorm:"foreignKey:TagID"` Aliases []TagAlias `json:"aliases" gorm:"foreignKey:TagID"`
Groups []TagGroup `json:"groups" gorm:"foreignKey:TagID"` Groups []TagGroup `json:"groups" gorm:"foreignKey:TagID"`
@ -15,8 +15,8 @@ func (Tag) TableName() string {
// TagAlias model // TagAlias model
type TagAlias struct { type TagAlias struct {
Name TagAliasName `json:"name" gorm:"primaryKey"` Name string `json:"name" gorm:"primaryKey"`
TagID TagName `json:"tag_id"` TagID string `json:"tag_id"`
} }
func (TagAlias) TableName() string { func (TagAlias) TableName() string {
@ -25,8 +25,8 @@ func (TagAlias) TableName() string {
// TagGroup model // TagGroup model
type TagGroup struct { type TagGroup struct {
Name TagGroupName `json:"name" gorm:"primaryKey"` Name string `json:"name" gorm:"primaryKey"`
TagID TagName `json:"tag_id"` TagID string `json:"tag_id"`
} }
func (TagGroup) TableName() string { func (TagGroup) TableName() string {