services

package
v0.0.0-...-33b7898 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlreadyExistsError

type AlreadyExistsError struct {
	// contains filtered or unexported fields
}

func (*AlreadyExistsError) Error

func (err *AlreadyExistsError) Error() string

type ArticlesService

type ArticlesService struct {
	// contains filtered or unexported fields
}

func NewArticlesService

func NewArticlesService(db *sql.DB, logger *slog.Logger, usersService *UsersService) ArticlesService

func (*ArticlesService) CreateArticle

func (articlesService *ArticlesService) CreateArticle(ctx context.Context, createArticle CreateArticle) (*model.Article, error)

func (*ArticlesService) CreateComment

func (articlesService *ArticlesService) CreateComment(ctx context.Context, articleId uuid.UUID, authorId uuid.UUID, body string) (*model.ArticleComment, error)

func (*ArticlesService) DeleteArticle

func (articlesService *ArticlesService) DeleteArticle(ctx context.Context, articleId uuid.UUID) error

func (*ArticlesService) DeleteComment

func (articlesService *ArticlesService) DeleteComment(ctx context.Context, commentId uuid.UUID) error

func (*ArticlesService) FavoriteArticle

func (articlesService *ArticlesService) FavoriteArticle(ctx context.Context, userId uuid.UUID, articleId uuid.UUID) error

func (*ArticlesService) GetArticleById

func (articlesService *ArticlesService) GetArticleById(ctx context.Context, articleId uuid.UUID) (*model.Article, error)

func (*ArticlesService) GetArticleBySlug

func (articlesService *ArticlesService) GetArticleBySlug(ctx context.Context, slug string) (*model.Article, error)

func (*ArticlesService) GetCommentById

func (articlesService *ArticlesService) GetCommentById(ctx context.Context, commentId uuid.UUID) (*model.ArticleComment, error)

func (*ArticlesService) GetFavoritesCount

func (articlesService *ArticlesService) GetFavoritesCount(ctx context.Context, articleId uuid.UUID) (*int, error)

func (*ArticlesService) IsFavorite

func (articlesService *ArticlesService) IsFavorite(ctx context.Context, userId uuid.UUID, articleId uuid.UUID) (*bool, error)

func (*ArticlesService) ListArticles

func (articlesService *ArticlesService) ListArticles(ctx context.Context, listArticles ListArticles) (*[]model.Article, error)

func (*ArticlesService) ListComments

func (articlesService *ArticlesService) ListComments(ctx context.Context, listComments ListComments) (*[]model.ArticleComment, error)

func (*ArticlesService) ListTags

func (articlesService *ArticlesService) ListTags(ctx context.Context, listTags ListTags) (*[]model.ArticleTag, error)

func (*ArticlesService) UnfavoriteArticle

func (articlesService *ArticlesService) UnfavoriteArticle(ctx context.Context, userId uuid.UUID, articleId uuid.UUID) error

func (*ArticlesService) UpdateArticle

func (articlesService *ArticlesService) UpdateArticle(ctx context.Context, articleId uuid.UUID, updateArticle UpdateArticle) (*model.Article, error)

type CreateArticle

type CreateArticle struct {
	AuthorID    uuid.UUID
	Title       string
	Description string
	Body        string
	TagList     *[]string
}

func NewCreateArticle

func NewCreateArticle(authorId uuid.UUID, title string, description string, body string, tagList *[]string) CreateArticle

type InvalidArgumentError

type InvalidArgumentError struct {
	// contains filtered or unexported fields
}

func (*InvalidArgumentError) Error

func (err *InvalidArgumentError) Error() string

type ListArticles

type ListArticles struct {
	AuthorIDs         *[]uuid.UUID
	FavoritedByUserID *uuid.UUID
	TagName           *string
	Limit             *int
	Offset            *int
}

type ListComments

type ListComments struct {
	ArticleID *uuid.UUID
}

type ListTags

type ListTags struct {
	ArticleID *uuid.UUID
}

type ListUsers

type ListUsers struct {
	UserIDs *[]uuid.UUID
}

type NotFoundError

type NotFoundError struct {
	// contains filtered or unexported fields
}

func (*NotFoundError) Error

func (err *NotFoundError) Error() string

type Profile

type Profile struct {
	UserID    uuid.UUID
	Username  string
	Bio       *string
	Image     *string
	Following bool
}

func NewProfile

func NewProfile(user model.Users, following bool) Profile

type ProfilesService

type ProfilesService struct {
	// contains filtered or unexported fields
}

func NewProfilesService

func NewProfilesService(db *sql.DB, logger *slog.Logger, usersService *UsersService) ProfilesService

func (*ProfilesService) FollowUser

func (profilesService *ProfilesService) FollowUser(ctx context.Context, followerId uuid.UUID, followedId uuid.UUID) error

func (*ProfilesService) GetProfile

func (profilesService *ProfilesService) GetProfile(ctx context.Context, userId uuid.UUID, followerId *uuid.UUID) (*Profile, error)

func (*ProfilesService) IsFollowing

func (profilesService *ProfilesService) IsFollowing(ctx context.Context, followerId uuid.UUID, followedId uuid.UUID) (*bool, error)

func (*ProfilesService) ListFollowedProfiles

func (profilesService *ProfilesService) ListFollowedProfiles(ctx context.Context, userId uuid.UUID) (*[]Profile, error)

func (*ProfilesService) UnfollowUser

func (profilesService *ProfilesService) UnfollowUser(ctx context.Context, followerId uuid.UUID, followedId uuid.UUID) error

type RegisterUser

type RegisterUser struct {
	Email    string
	Username string
	Password string
}

func NewRegisterUser

func NewRegisterUser(email string, username string, password string) RegisterUser

type UpdateArticle

type UpdateArticle struct {
	Title       *string
	Description *string
	Body        *string
}

type UpdateUser

type UpdateUser struct {
	Email    *string
	Username *string
	Password *string
	Bio      *string
	Image    *string
}

type UsersService

type UsersService struct {
	// contains filtered or unexported fields
}

func NewUsersService

func NewUsersService(db *sql.DB, jwt *UsersServiceJWT, logger *slog.Logger) UsersService

func (*UsersService) CheckPassword

func (usersService *UsersService) CheckPassword(ctx context.Context, userId uuid.UUID, password string) (*bool, error)

func (*UsersService) GetToken

func (usersService *UsersService) GetToken(ctx context.Context, user *model.Users) (*string, error)

func (*UsersService) GetUserByEmail

func (usersService *UsersService) GetUserByEmail(ctx context.Context, email string) (*model.Users, error)

func (*UsersService) GetUserById

func (usersService *UsersService) GetUserById(ctx context.Context, userId uuid.UUID) (*model.Users, error)

func (*UsersService) GetUserByToken

func (usersService *UsersService) GetUserByToken(ctx context.Context, token string) (*model.Users, error)

func (*UsersService) GetUserByUsername

func (usersService *UsersService) GetUserByUsername(ctx context.Context, username string) (*model.Users, error)

func (*UsersService) ListUsers

func (usersService *UsersService) ListUsers(ctx context.Context, listUsers ListUsers) (*[]model.Users, error)

func (*UsersService) RegisterUser

func (usersService *UsersService) RegisterUser(ctx context.Context, registerUser RegisterUser) (*model.Users, error)

func (*UsersService) UpdateUser

func (usersService *UsersService) UpdateUser(ctx context.Context, userId uuid.UUID, updateUser UpdateUser) (*model.Users, error)

type UsersServiceJWT

type UsersServiceJWT struct {
	// contains filtered or unexported fields
}

func NewUsersServiceJWT

func NewUsersServiceJWT(iss string, key []byte, validForSeconds int) UsersServiceJWT

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL