2026-03-26 01:56:29 +07:00

33 lines
541 B
Go

package schedule_storage
import (
"encoding/json"
"log"
"os"
"pinned_message/internal/models"
)
type ScheduleStorage struct {
filepath string
}
func NewScheduleStorage(
filepath string,
) *ScheduleStorage {
return &ScheduleStorage{
filepath: filepath,
}
}
func (s *ScheduleStorage) SaveSchedule(days []*models.Day) error {
data, err := json.Marshal(days)
if err != nil {
return err
}
if err := os.WriteFile(s.filepath, data, 0x777); err != nil {
return err
}
log.Printf("save story to: %s", s.filepath)
return nil
}