парсер
This commit is contained in:
38
tg_parser/internal/usecase/usecase.go
Normal file
38
tg_parser/internal/usecase/usecase.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package usecase
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/TelegramExchange/tgex-parser/internal/domain"
|
||||
)
|
||||
|
||||
type Telegram interface {
|
||||
ParseChannelMeta(ctx context.Context, username string) (domain.Channel, error)
|
||||
GetChannelHistory(ctx context.Context, channel domain.Channel, limit int) ([]domain.Post, error)
|
||||
GetChannelDiff(ctx context.Context, channel domain.Channel, limit int) (domain.ChannelDiff, error)
|
||||
UpdatePostsViews(ctx context.Context, channel domain.Channel, posts []domain.Post) error
|
||||
}
|
||||
|
||||
type Database interface {
|
||||
CreatePost(ctx context.Context, post domain.Post) error
|
||||
|
||||
CreateViewsSnapshot(ctx context.Context, snapshot domain.ViewsSnapshot) error
|
||||
|
||||
GetChannels(ctx context.Context) []domain.Channel
|
||||
UpdateChannel(ctx context.Context, channel domain.Channel) error
|
||||
GetChannelsWithTrackedPosts(ctx context.Context) ([]domain.Channel, error)
|
||||
GetTrackedPosts(ctx context.Context, channel domain.Channel) ([]domain.Post, error)
|
||||
DeletePost(ctx context.Context, p domain.Post) error
|
||||
}
|
||||
|
||||
type UseCase struct {
|
||||
telegram Telegram
|
||||
database Database
|
||||
}
|
||||
|
||||
func New(telegram Telegram, database Database) *UseCase {
|
||||
return &UseCase{
|
||||
telegram: telegram,
|
||||
database: database,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user