service

package
v0.0.0-...-3c0f6d4 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth interface {
	Register(ctx context.Context, user *entity.User) (*entity.UserWithToken, error)
	Update(ctx context.Context, user *entity.User) (*entity.User, error)
	Delete(ctx context.Context, userID uuid.UUID) error
	GetUserByID(ctx context.Context, userID uuid.UUID) (*entity.User, error)
	FindUsersByName(ctx context.Context, name string, pq *utils.PaginationQuery) (*entity.UsersList, error)
	GetUsers(ctx context.Context, pq *utils.PaginationQuery) (*entity.UsersList, error)
	Login(ctx context.Context, user *entity.User) (*entity.UserWithToken, error)
}

Auth Service interface

type AuthPsql

type AuthPsql interface {
	Register(ctx context.Context, user *entity.User) (*entity.User, error)
	Update(ctx context.Context, user *entity.User) (*entity.User, error)
	Delete(ctx context.Context, userID uuid.UUID) error
	GetUserByID(ctx context.Context, userID uuid.UUID) (*entity.User, error)
	FindUsersByName(ctx context.Context, name string, pq *utils.PaginationQuery) (*entity.UsersList, error)
	GetUsers(ctx context.Context, pq *utils.PaginationQuery) (*entity.UsersList, error)
	FindUserByEmail(ctx context.Context, user *entity.User) (*entity.User, error)
}

Auth StoragePsql interface

type AuthRedis

type AuthRedis interface {
	GetByIDCtx(ctx context.Context, key string) (*entity.User, error)
	SetUserCtx(ctx context.Context, key string, seconds int, user *entity.User) error
	DeleteUserCtx(ctx context.Context, key string) error
}

Auth StorageRedis interface

type AuthService

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

Auth service

func NewAuthService

func NewAuthService(config *config.Config, storagePsql AuthPsql, storageRedis AuthRedis, logger logger.Logger) *AuthService

Auth service constructor

func (*AuthService) Delete

func (a *AuthService) Delete(ctx context.Context, userID uuid.UUID) error

Delete user

func (*AuthService) FindUsersByName

func (a *AuthService) FindUsersByName(ctx context.Context, name string,
	pq *utils.PaginationQuery) (*entity.UsersList, error)

Find users by name

func (*AuthService) GetUserByID

func (a *AuthService) GetUserByID(ctx context.Context, userID uuid.UUID) (*entity.User, error)

Get user by id

func (*AuthService) GetUsers

Get users

func (*AuthService) Login

func (a *AuthService) Login(ctx context.Context, user *entity.User) (*entity.UserWithToken, error)

Login user, returns user model with jwt token

func (*AuthService) Register

func (a *AuthService) Register(ctx context.Context, user *entity.User) (*entity.UserWithToken, error)

Register new user

func (*AuthService) Update

func (a *AuthService) Update(ctx context.Context, user *entity.User) (*entity.User, error)

Update user

type Comments

type Comments interface {
	Create(ctx context.Context, comments *entity.Comment) (*entity.Comment, error)
	Update(ctx context.Context, comments *entity.Comment) (*entity.Comment, error)
	GetAllByNewsID(ctx context.Context, newsID uuid.UUID, pq *utils.PaginationQuery) (*entity.CommentsList, error)
	GetByID(ctx context.Context, commentID uuid.UUID) (*entity.CommentBase, error)
	Delete(ctx context.Context, commentID uuid.UUID) error
}

Comments Service interface

type CommentsPsql

type CommentsPsql interface {
	Create(ctx context.Context, comments *entity.Comment) (*entity.Comment, error)
	Update(ctx context.Context, comments *entity.Comment) (*entity.Comment, error)
	GetByID(ctx context.Context, commentID uuid.UUID) (*entity.CommentBase, error)
	GetAllByNewsID(ctx context.Context, newsID uuid.UUID, pq *utils.PaginationQuery) (*entity.CommentsList, error)
	Delete(ctx context.Context, commentID uuid.UUID) error
}

Comments storage interface

type CommentsService

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

Comments service

func NewCommentsService

func NewCommentsService(config *config.Config, commentsStorage CommentsPsql, logger logger.Logger) *CommentsService

Comments service constructor

func (*CommentsService) Create

func (c *CommentsService) Create(ctx context.Context, comments *entity.Comment) (*entity.Comment, error)

Create comments

func (*CommentsService) Delete

func (c *CommentsService) Delete(ctx context.Context, commentID uuid.UUID) error

Delete comments

func (*CommentsService) GetAllByNewsID

func (c *CommentsService) GetAllByNewsID(ctx context.Context,
	newsID uuid.UUID, pq *utils.PaginationQuery) (*entity.CommentsList, error)

Get comments by news id

func (*CommentsService) GetByID

func (c *CommentsService) GetByID(ctx context.Context, commentID uuid.UUID) (*entity.CommentBase, error)

Get comment by id

func (*CommentsService) Update

func (c *CommentsService) Update(ctx context.Context, comment *entity.Comment) (*entity.Comment, error)

Update comments

type Deps

type Deps struct {
	Logger       logger.Logger
	Config       *config.Config
	PsqlStorage  *psql.Storage
	RedisStorage *redisrepo.Storage
}

type News

type News interface {
	Create(ctx context.Context, news *entity.News) (*entity.News, error)
	Update(ctx context.Context, news *entity.News) (*entity.News, error)
	GetNews(ctx context.Context, pq *utils.PaginationQuery) (*entity.NewsList, error)
	GetNewsByID(ctx context.Context, newsID uuid.UUID) (*entity.NewsBase, error)
	SearchNews(ctx context.Context, title string, pq *utils.PaginationQuery) (*entity.NewsList, error)
	Delete(ctx context.Context, newsID uuid.UUID) error
}

News service interface

type NewsPsql

type NewsPsql interface {
	Create(ctx context.Context, news *entity.News) (*entity.News, error)
	Update(ctx context.Context, news *entity.News) (*entity.News, error)
	GetNews(ctx context.Context, pq *utils.PaginationQuery) (*entity.NewsList, error)
	GetNewsByID(ctx context.Context, newsID uuid.UUID) (*entity.NewsBase, error)
	SearchNews(ctx context.Context, title string, pq *utils.PaginationQuery) (*entity.NewsList, error)
	Delete(ctx context.Context, newsID uuid.UUID) error
}

News StoragePsql interface

type NewsRedis

type NewsRedis interface {
	GetNewsByIDCtx(ctx context.Context, key string) (*entity.NewsBase, error)
	SetNewsCtx(ctx context.Context, key string, seconds int, news *entity.NewsBase) error
	DeleteNewsCtx(ctx context.Context, key string) error
}

News StorageRedis interface

type NewsService

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

News service

func NewNewsService

func NewNewsService(config *config.Config, storagePsql NewsPsql, redis NewsRedis, logger logger.Logger) *NewsService

News service constructor

func (*NewsService) Create

func (n *NewsService) Create(ctx context.Context, news *entity.News) (*entity.News, error)

Create news

func (*NewsService) Delete

func (n *NewsService) Delete(ctx context.Context, newsID uuid.UUID) error

Delete news by id

func (*NewsService) GetNews

Get news

func (*NewsService) GetNewsByID

func (n *NewsService) GetNewsByID(ctx context.Context, newsID uuid.UUID) (*entity.NewsBase, error)

Get single news by id

func (*NewsService) SearchNews

func (n *NewsService) SearchNews(ctx context.Context, title string, pq *utils.PaginationQuery) (*entity.NewsList, error)

Find news by title

func (*NewsService) Update

func (n *NewsService) Update(ctx context.Context, news *entity.News) (*entity.News, error)

Update news items

type Services

type Services struct {
	Auth     *AuthService
	News     *NewsService
	Comments *CommentsService
	Session  *SessionService
}

func NewService

func NewService(deps Deps) *Services

type Session

type Session interface {
	CreateSession(ctx context.Context, session *entity.Session, expire int) (string, error)
	GetSessionByID(ctx context.Context, sessionID string) (*entity.Session, error)
	DeleteSessionByID(ctx context.Context, sessionID string) error
}

Session service interface

type SessionRedis

type SessionRedis interface {
	CreateSession(ctx context.Context, session *entity.Session, expire int) (string, error)
	GetSessionByID(ctx context.Context, sessionID string) (*entity.Session, error)
	DeleteSessionByID(ctx context.Context, sessionID string) error
}

Session redis storage interface

type SessionService

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

Session service

func NewSessionService

func NewSessionService(config *config.Config, sessionStorage SessionRedis, logger logger.Logger) *SessionService

SessionService constructor

func (*SessionService) CreateSession

func (s *SessionService) CreateSession(ctx context.Context, session *entity.Session, expire int) (string, error)

Create session

func (*SessionService) DeleteSessionByID

func (s *SessionService) DeleteSessionByID(ctx context.Context, sessionID string) error

Delete session by id

func (*SessionService) GetSessionByID

func (s *SessionService) GetSessionByID(ctx context.Context, sessionID string) (*entity.Session, error)

Get session by id

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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