planner/sync-service/planner.go

52 lines
766 B
Go
Raw Normal View History

2024-09-08 10:09:54 +02:00
package main
2024-08-20 08:34:11 +02:00
import (
"time"
"github.com/google/uuid"
)
2024-09-08 11:17:49 +02:00
type Kind string
const (
KindTask Kind = "task"
)
2024-09-09 07:36:05 +02:00
type Item struct {
2024-09-09 07:32:05 +02:00
ID string `json:"id"`
Kind Kind `json:"kind"`
Updated time.Time `json:"updated"`
Deleted bool `json:"deleted"`
2024-09-09 07:36:05 +02:00
Body string `json:"body"`
2024-08-28 07:21:02 +02:00
}
2024-09-09 07:36:05 +02:00
func NewItem(body string) Item {
return Item{
2024-08-28 07:21:02 +02:00
ID: uuid.New().String(),
Updated: time.Now(),
2024-09-09 07:36:05 +02:00
Body: body,
2024-08-28 07:21:02 +02:00
}
2024-08-20 08:34:11 +02:00
}
type Task struct {
2024-08-21 16:35:44 +02:00
id string
2024-08-20 08:34:11 +02:00
description string
updated time.Time
}
func NewTask(description string) Task {
return Task{
2024-08-21 16:35:44 +02:00
id: uuid.New().String(),
2024-08-20 08:34:11 +02:00
description: description,
updated: time.Now(),
}
}
2024-08-21 16:35:44 +02:00
2024-08-23 08:19:04 +02:00
func (t Task) ID() string {
2024-08-21 16:35:44 +02:00
return t.id
}
2024-08-23 08:19:04 +02:00
func (t Task) Updated() time.Time {
2024-08-21 16:35:44 +02:00
return t.updated
}