generated from VLADIMIR/template
add route
This commit is contained in:
@@ -2,6 +2,7 @@ package schedule_storage
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"pinned_message/internal/models"
|
||||
@@ -30,3 +31,16 @@ func (s *ScheduleStorage) SaveSchedule(days []*models.Day) error {
|
||||
log.Printf("save story to: %s", s.filepath)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ScheduleStorage) GetSchedule() ([]*models.Day, error) {
|
||||
data, err := os.ReadFile(s.filepath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("story file %s not found", s.filepath)
|
||||
}
|
||||
log.Printf("load story from: %s", s.filepath)
|
||||
days := []*models.Day{}
|
||||
if err := json.Unmarshal(data, &days); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return days, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user