Documentation
¶
Index ¶
- type Auth
- type AuthPsql
- type AuthRedis
- type AuthService
- func (a *AuthService) Delete(ctx context.Context, userID uuid.UUID) error
- func (a *AuthService) FindUsersByName(ctx context.Context, name string, pq *utils.PaginationQuery) (*entity.UsersList, error)
- func (a *AuthService) GetUserByID(ctx context.Context, userID uuid.UUID) (*entity.User, error)
- func (a *AuthService) GetUsers(ctx context.Context, pq *utils.PaginationQuery) (*entity.UsersList, error)
- func (a *AuthService) Login(ctx context.Context, user *entity.User) (*entity.UserWithToken, error)
- func (a *AuthService) Register(ctx context.Context, user *entity.User) (*entity.UserWithToken, error)
- func (a *AuthService) Update(ctx context.Context, user *entity.User) (*entity.User, error)
- type Comments
- type CommentsPsql
- type CommentsService
- func (c *CommentsService) Create(ctx context.Context, comments *entity.Comment) (*entity.Comment, error)
- func (c *CommentsService) Delete(ctx context.Context, commentID uuid.UUID) error
- func (c *CommentsService) GetAllByNewsID(ctx context.Context, newsID uuid.UUID, pq *utils.PaginationQuery) (*entity.CommentsList, error)
- func (c *CommentsService) GetByID(ctx context.Context, commentID uuid.UUID) (*entity.CommentBase, error)
- func (c *CommentsService) Update(ctx context.Context, comment *entity.Comment) (*entity.Comment, error)
- type Deps
- type News
- type NewsPsql
- type NewsRedis
- type NewsService
- func (n *NewsService) Create(ctx context.Context, news *entity.News) (*entity.News, error)
- func (n *NewsService) Delete(ctx context.Context, newsID uuid.UUID) error
- func (n *NewsService) GetNews(ctx context.Context, pq *utils.PaginationQuery) (*entity.NewsList, error)
- func (n *NewsService) GetNewsByID(ctx context.Context, newsID uuid.UUID) (*entity.NewsBase, error)
- func (n *NewsService) SearchNews(ctx context.Context, title string, pq *utils.PaginationQuery) (*entity.NewsList, error)
- func (n *NewsService) Update(ctx context.Context, news *entity.News) (*entity.News, error)
- type Services
- type Session
- type SessionRedis
- type SessionService
- func (s *SessionService) CreateSession(ctx context.Context, session *entity.Session, expire int) (string, error)
- func (s *SessionService) DeleteSessionByID(ctx context.Context, sessionID string) error
- func (s *SessionService) GetSessionByID(ctx context.Context, sessionID string) (*entity.Session, error)
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) FindUsersByName ¶
func (a *AuthService) FindUsersByName(ctx context.Context, name string, pq *utils.PaginationQuery) (*entity.UsersList, error)
Find users by name
func (*AuthService) GetUserByID ¶
Get user by id
func (*AuthService) GetUsers ¶
func (a *AuthService) GetUsers(ctx context.Context, pq *utils.PaginationQuery) (*entity.UsersList, error)
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
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) 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
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) GetNews ¶
func (n *NewsService) GetNews(ctx context.Context, pq *utils.PaginationQuery) (*entity.NewsList, error)
Get news
func (*NewsService) GetNewsByID ¶
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
type Services ¶
type Services struct { Auth *AuthService News *NewsService Comments *CommentsService Session *SessionService }
func NewService ¶
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