first commit
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"effective_mobile_test_go_api/internal/model"
|
||||
"effective_mobile_test_go_api/internal/repo"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type SubscriptionService struct {
|
||||
repo *repo.SubscriptionRepo
|
||||
}
|
||||
|
||||
func NewSubscriptionService(r *repo.SubscriptionRepo) *SubscriptionService {
|
||||
return &SubscriptionService{repo: r}
|
||||
}
|
||||
|
||||
func (s *SubscriptionService) Create(ctx context.Context, sub *model.Subscription) error {
|
||||
return s.repo.Create(ctx, sub)
|
||||
}
|
||||
|
||||
func (s *SubscriptionService) GetByID(ctx context.Context, id int) (*model.Subscription, error) {
|
||||
return s.repo.GetByID(ctx, id)
|
||||
}
|
||||
|
||||
func (s *SubscriptionService) Update(ctx context.Context, sub *model.Subscription) error {
|
||||
return s.repo.Update(ctx, sub)
|
||||
}
|
||||
|
||||
func (s *SubscriptionService) Delete(ctx context.Context, id int) error {
|
||||
return s.repo.Delete(ctx, id)
|
||||
}
|
||||
|
||||
func (s *SubscriptionService) List(ctx context.Context) ([]*model.Subscription, error) {
|
||||
return s.repo.List(ctx)
|
||||
}
|
||||
|
||||
func (s *SubscriptionService) SumPrice(ctx context.Context, userID *uuid.UUID, serviceName string, startPeriod, endPeriod time.Time) (int, error) {
|
||||
return s.repo.SumPrice(ctx, userID, serviceName, startPeriod, endPeriod)
|
||||
}
|
||||
Reference in New Issue
Block a user