planner/item/item.go

36 lines
529 B
Go
Raw Normal View History

2024-09-18 07:55:14 +02:00
package item
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 (
2024-09-11 07:33:22 +02:00
KindTask Kind = "task"
KindEvent Kind = "event"
)
var (
KnownKinds = []Kind{KindTask, KindEvent}
2024-09-08 11:17:49 +02:00
)
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-11 07:33:22 +02:00
func NewItem(k Kind, body string) Item {
2024-09-09 07:36:05 +02:00
return Item{
2024-08-28 07:21:02 +02:00
ID: uuid.New().String(),
2024-09-11 07:33:22 +02:00
Kind: k,
2024-08-28 07:21:02 +02:00
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
}