|
|
|
@ -13,11 +13,11 @@ import (
|
|
|
|
|
func CreateUser(ctx context.Context, db *gorm.DB, anthroveUserID models.AnthroveUserID) error {
|
|
|
|
|
|
|
|
|
|
if anthroveUserID == "" {
|
|
|
|
|
return &errors2.EntityValidationFailed{Reason: "anthroveUserID cannot be empty"}
|
|
|
|
|
return &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(anthroveUserID) != 25 {
|
|
|
|
|
return &errors2.EntityValidationFailed{Reason: "anthroveUserID needs to be 25 characters long"}
|
|
|
|
|
return &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
user := models.User{
|
|
|
|
@ -40,11 +40,11 @@ func CreateUser(ctx context.Context, db *gorm.DB, anthroveUserID models.Anthrove
|
|
|
|
|
func CreateUserWithRelationToSource(ctx context.Context, db *gorm.DB, anthroveUserID models.AnthroveUserID, sourceID models.AnthroveSourceID, accountId string, accountUsername string) error {
|
|
|
|
|
|
|
|
|
|
if anthroveUserID == "" {
|
|
|
|
|
return &errors2.EntityValidationFailed{Reason: "anthroveUserID cannot be empty"}
|
|
|
|
|
return &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(anthroveUserID) != 25 {
|
|
|
|
|
return &errors2.EntityValidationFailed{Reason: "anthroveUserID needs to be 25 characters long"}
|
|
|
|
|
return &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if accountId == "" {
|
|
|
|
@ -103,11 +103,11 @@ func GetUserFavoritesCount(ctx context.Context, db *gorm.DB, anthroveUserID mode
|
|
|
|
|
var count int64
|
|
|
|
|
|
|
|
|
|
if anthroveUserID == "" {
|
|
|
|
|
return 0, &errors2.EntityValidationFailed{Reason: "anthroveUserID cannot be empty"}
|
|
|
|
|
return 0, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(anthroveUserID) != 25 {
|
|
|
|
|
return 0, &errors2.EntityValidationFailed{Reason: "anthroveUserID needs to be 25 characters long"}
|
|
|
|
|
return 0, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result := db.WithContext(ctx).Model(&models.UserFavorites{}).Where("user_id = ?", string(anthroveUserID)).Count(&count)
|
|
|
|
@ -131,11 +131,11 @@ func GetUserSourceLinks(ctx context.Context, db *gorm.DB, anthroveUserID models.
|
|
|
|
|
userSourceMap := make(map[string]models.UserSource)
|
|
|
|
|
|
|
|
|
|
if anthroveUserID == "" {
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: "anthroveUserID cannot be empty"}
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(anthroveUserID) != 25 {
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: "anthroveUserID needs to be 25 characters long"}
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result := db.WithContext(ctx).Model(&models.UserSource{}).Where("user_id = ?", string(anthroveUserID)).Find(&userSources)
|
|
|
|
@ -179,11 +179,11 @@ func GetUserSourceBySourceID(ctx context.Context, db *gorm.DB, anthroveUserID mo
|
|
|
|
|
userSourceMap := make(map[string]models.UserSource)
|
|
|
|
|
|
|
|
|
|
if anthroveUserID == "" {
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: "anthroveUserID cannot be empty"}
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(anthroveUserID) != 25 {
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: "anthroveUserID needs to be 25 characters long"}
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if sourceID == "" {
|
|
|
|
@ -259,11 +259,11 @@ func GetUserFavoriteWithPagination(ctx context.Context, db *gorm.DB, anthroveUse
|
|
|
|
|
var favoritePosts []models.Post
|
|
|
|
|
|
|
|
|
|
if anthroveUserID == "" {
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: "anthroveUserID cannot be empty"}
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(anthroveUserID) != 25 {
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: "anthroveUserID needs to be 25 characters long"}
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err := db.WithContext(ctx).Model(&models.UserFavorites{}).Where("user_id = ?", string(anthroveUserID)).Offset(skip).Limit(limit).Find(&userFavorites).Error
|
|
|
|
@ -303,11 +303,11 @@ func GetUserTagWitRelationToFavedPosts(ctx context.Context, db *gorm.DB, anthrov
|
|
|
|
|
var userFavorites []models.UserFavorites
|
|
|
|
|
|
|
|
|
|
if anthroveUserID == "" {
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: "anthroveUserID cannot be empty"}
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDIsEmpty}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(anthroveUserID) != 25 {
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: "anthroveUserID needs to be 25 characters long"}
|
|
|
|
|
return nil, &errors2.EntityValidationFailed{Reason: errors2.AnthroveUserIDToShort}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result := db.WithContext(ctx).Where("user_id = ?", string(anthroveUserID)).Find(&userFavorites)
|
|
|
|
|