service

package
v0.0.0-...-01c8ee1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Repos           *repository.Repositories
	Hasher          hash.PasswordHasher
	TokenManager    auth.TokenManager
	AccessTokenTTL  time.Duration
	RefreshTokenTTL time.Duration
	Storage         *storage.GDriveStorage
}

type Operations

type Operations interface {
	CreateRelationsBySegmentIDs(ctx context.Context, userId int, segmentIDs []int) ([]int, error)
	CreateRelationsBySegmentNames(ctx context.Context, userId int, segmentsNames []string) ([]int, error)
	DeleteRelationsBySegmentIDs(ctx context.Context, userId int, segmentIDs []int) ([]int, error)
	DeleteRelationsBySegmentNames(ctx context.Context, userId int, segmentsNames []string) ([]int, error)
	DeleteRelationsAfterTTLBySegmentIDs(ctx context.Context, userId int, segmentIDs []int, ttl time.Duration)
	DeleteRelationsAfterTTLBySegmentNames(ctx context.Context, userId int, segmentsNames []string, ttl time.Duration)
	GetOperationsHistory(ctx context.Context, year, month int, userIDs ...int) ([]entity.Operation, error)
}

type OperationsService

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

func NewOperations

func NewOperations(usersRepo repository.Users, segmentsRepo repository.Segments,
	operationsRepo repository.Operations) *OperationsService

func (*OperationsService) CreateRelationsBySegmentIDs

func (o *OperationsService) CreateRelationsBySegmentIDs(ctx context.Context, userId int, segmentIDs []int) ([]int, error)

func (*OperationsService) CreateRelationsBySegmentNames

func (o *OperationsService) CreateRelationsBySegmentNames(ctx context.Context, userId int, segmentsNames []string) ([]int, error)

func (*OperationsService) DeleteRelationsAfterTTLBySegmentIDs

func (o *OperationsService) DeleteRelationsAfterTTLBySegmentIDs(ctx context.Context, userId int, segmentsIDs []int, ttl time.Duration)

func (*OperationsService) DeleteRelationsAfterTTLBySegmentNames

func (o *OperationsService) DeleteRelationsAfterTTLBySegmentNames(ctx context.Context, userId int, segmentsNames []string, ttl time.Duration)

func (*OperationsService) DeleteRelationsBySegmentIDs

func (o *OperationsService) DeleteRelationsBySegmentIDs(ctx context.Context, userId int, segmentIDs []int) ([]int, error)

func (*OperationsService) DeleteRelationsBySegmentNames

func (o *OperationsService) DeleteRelationsBySegmentNames(ctx context.Context, userId int, segmentsNames []string) ([]int, error)

func (*OperationsService) GetOperationsHistory

func (o *OperationsService) GetOperationsHistory(ctx context.Context, year, month int, userIDs ...int) ([]entity.Operation, error)

type Reports

type Reports interface {
	CreateReportFile(ctx context.Context, year, month int, userIDs ...int) ([]byte, error)
	CreateReportLink(ctx context.Context, year, month int, userIDs ...int) (string, error)
}

type ReportsService

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

func NewReports

func NewReports(repo repository.Operations, storage storage.Provider) *ReportsService

func (*ReportsService) CreateReportFile

func (r *ReportsService) CreateReportFile(ctx context.Context, year, month int, userIDs ...int) ([]byte, error)
func (r *ReportsService) CreateReportLink(ctx context.Context, year, month int, userIDs ...int) (string, error)

type Segments

type Segments interface {
	Create(ctx context.Context, segment entity.Segment) (int, error)
	GetByID(ctx context.Context, id int) (entity.Segment, error)
	GetActiveUsersBySegmentID(ctx context.Context, id int) ([]entity.User, error)
	GetAll(ctx context.Context) ([]entity.Segment, error)
	DeleteByName(ctx context.Context, name string) error
	DeleteByID(ctx context.Context, id int) error
}

type SegmentsService

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

func NewSegments

func NewSegments(segmentsRepo repository.Segments, usersRepo repository.Users) *SegmentsService

func (*SegmentsService) Create

func (s *SegmentsService) Create(ctx context.Context, segment entity.Segment) (int, error)

func (*SegmentsService) DeleteByID

func (s *SegmentsService) DeleteByID(ctx context.Context, id int) error

func (*SegmentsService) DeleteByName

func (s *SegmentsService) DeleteByName(ctx context.Context, name string) error

func (*SegmentsService) GetActiveUsersBySegmentID

func (s *SegmentsService) GetActiveUsersBySegmentID(ctx context.Context, id int) ([]entity.User, error)

func (*SegmentsService) GetAll

func (s *SegmentsService) GetAll(ctx context.Context) ([]entity.Segment, error)

func (*SegmentsService) GetByID

func (s *SegmentsService) GetByID(ctx context.Context, id int) (entity.Segment, error)

type Services

type Services struct {
	Users
	Segments
	Operations
	Reports
}

func New

func New(deps Deps) *Services

type Tokens

type Tokens struct {
	AccessToken  string
	RefreshToken string
}

type UserService

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

func NewUsers

func NewUsers(repo repository.Users, hasher hash.PasswordHasher, tokenManager auth.TokenManager, accessTokenTTL, refreshTokenTTL time.Duration) *UserService

func (*UserService) GetActiveSegmentsByUserID

func (u *UserService) GetActiveSegmentsByUserID(ctx context.Context, id int) ([]entity.Segment, error)

func (*UserService) RefreshTokens

func (u *UserService) RefreshTokens(ctx context.Context, refreshToken string) (Tokens, error)

func (*UserService) SignIn

func (u *UserService) SignIn(ctx context.Context, login, password string) (Tokens, error)

func (*UserService) SignUp

func (u *UserService) SignUp(ctx context.Context, login, email, password string) (int, error)

type Users

type Users interface {
	SignUp(ctx context.Context, login, email, password string) (int, error)
	SignIn(ctx context.Context, login, password string) (Tokens, error)
	RefreshTokens(ctx context.Context, refreshToken string) (Tokens, error)
	GetActiveSegmentsByUserID(ctx context.Context, id int) ([]entity.Segment, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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