service

package
v0.0.0-...-f96b8b0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACTIVATION   = "notifications.mail.activation"
	RESET_TOKENS = "notifications.mail.reset_tokens"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivationMailData

type ActivationMailData struct {
	To   []string
	Link string
}

type Article

type Article interface {
	Create(ctx context.Context, article *model.Article) error
	FindByID(ctx context.Context, id int64) (*model.ArticleDto, error)
	Search(ctx context.Context, query string) ([]*model.Article, error)
	FindAuthorArticles(ctx context.Context, authorID string) ([]*model.Article, error)
	FindLastArticles(ctx context.Context, limit int) ([]*model.ArticleDto, error)
}

type ArticleService

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

func NewArticleRepo

func NewArticleRepo(repo *repository.Repository, rdb *redis.Client) *ArticleService

func (*ArticleService) Create

func (s *ArticleService) Create(ctx context.Context, article *model.Article) error

func (*ArticleService) FindAuthorArticles

func (s *ArticleService) FindAuthorArticles(ctx context.Context, authorID string) ([]*model.Article, error)

func (*ArticleService) FindByID

func (s *ArticleService) FindByID(ctx context.Context, id int64) (*model.ArticleDto, error)

func (*ArticleService) FindLastArticles

func (s *ArticleService) FindLastArticles(ctx context.Context, limit int) ([]*model.ArticleDto, error)

func (*ArticleService) Search

func (s *ArticleService) Search(ctx context.Context, query string) ([]*model.Article, error)

type AuthService

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

func NewAuthService

func NewAuthService(repo *repository.Repository, rabbitMQ *mq.MQConn, rdb *redis.Client) *AuthService

func (*AuthService) Activate

func (s *AuthService) Activate(ctx context.Context, activationLink string) error

func (*AuthService) FindResetPasswordToken

func (s *AuthService) FindResetPasswordToken(token string) (*model.ResetPasswordToken, error)

func (*AuthService) ResetPassword

func (s *AuthService) ResetPassword(token string, newPassword string) error

func (*AuthService) SaveResetPasswordToken

func (s *AuthService) SaveResetPasswordToken(token *model.ResetPasswordToken) error

func (*AuthService) SignIn

func (s *AuthService) SignIn(user *model.User) (string, error)

func (*AuthService) SignUp

func (s *AuthService) SignUp(user *model.User) (string, error)

type Authorization

type Authorization interface {
	SignUp(user *model.User) (string, error)
	SignIn(user *model.User) (string, error)
	Activate(ctx context.Context, activationLink string) error
	SaveResetPasswordToken(token *model.ResetPasswordToken) error
	ResetPassword(token string, newPassword string) error
}

type Comment

type Comment interface {
	Create(ctx context.Context, comment *model.Comment) error
	FindArticleComments(ctx context.Context, articleID int64) ([]*model.CommentDto, error)
	Delete(ctx context.Context, commentID int64, userID uuid.UUID) error
}

type CommentService

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

func NewCommentService

func NewCommentService(repo *repository.Repository, rdb *redis.Client) *CommentService

func (*CommentService) Create

func (s *CommentService) Create(ctx context.Context, comment *model.Comment) error

func (*CommentService) Delete

func (s *CommentService) Delete(ctx context.Context, commentID int64, userID uuid.UUID) error

func (*CommentService) FindArticleComments

func (s *CommentService) FindArticleComments(ctx context.Context, articleID int64) ([]*model.CommentDto, error)

type Mail

type Mail interface {
	ProcessActivationMails()
	SendActivationMail(to []string, link string) error
	ProcessResetPasswordTokenMails()
	SendResetPasswordToken(to []string, link string) error
}

type MailService

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

func NewMailService

func NewMailService(rabbitMQ *mq.MQConn) *MailService

func (*MailService) ProcessActivationMails

func (s *MailService) ProcessActivationMails()

func (*MailService) ProcessResetPasswordTokenMails

func (s *MailService) ProcessResetPasswordTokenMails()

func (*MailService) SendActivationMail

func (s *MailService) SendActivationMail(to []string, link string) error

func (*MailService) SendResetPasswordToken

func (s *MailService) SendResetPasswordToken(to []string, token string) error

type ResetPasswordTokenMailData

type ResetPasswordTokenMailData struct {
	To    []string
	Token string
}

type Service

type Service struct {
	Authorization
	Mail
	User
	Article
	Comment
}

func New

func New(repo *repository.Repository, rdb *redis.Client, rabbitMQ *mq.MQConn) *Service

type User

type User interface {
	FindByID(ctx context.Context, id uuid.UUID) (*model.User, error)
	FindByUsername(ctx context.Context, username string) (*model.User, error)
	UpdateAvatar(c *gin.Context, userID uuid.UUID, file *multipart.FileHeader) error
}

type UserService

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

func NewUserService

func NewUserService(repo *repository.Repository, rdb *redis.Client) *UserService

func (*UserService) FindByID

func (s *UserService) FindByID(ctx context.Context, id uuid.UUID) (*model.User, error)

func (*UserService) FindByUsername

func (s *UserService) FindByUsername(ctx context.Context, username string) (*model.User, error)

func (*UserService) UpdateAvatar

func (s *UserService) UpdateAvatar(c *gin.Context, userID uuid.UUID, image *multipart.FileHeader) error

Jump to

Keyboard shortcuts

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