add route

This commit is contained in:
2026-03-26 02:23:36 +07:00
parent 9f9ffaa55f
commit 0a6294a62f
12 changed files with 864 additions and 22 deletions
@@ -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
}