add load and save to sats service
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||
"github.com/LazyBachelor/LazyPM/internal/storage"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type StatisticsService struct {
|
||||
@@ -19,6 +21,14 @@ func NewStatisticsService(storage *storage.Storage[models.Statistics]) (*Statist
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *StatisticsService) Load(ctx context.Context) error {
|
||||
return s.storage.Load()
|
||||
}
|
||||
|
||||
func (s *StatisticsService) Save(ctx context.Context) error {
|
||||
return s.storage.Save()
|
||||
}
|
||||
|
||||
func (s *StatisticsService) GetStatistics() (models.Statistics, error) {
|
||||
if s.storage.Data == nil {
|
||||
return models.Statistics{}, errors.New("statistics data not initialized")
|
||||
|
||||
Reference in New Issue
Block a user