Initial commit

This commit is contained in:
Kevin Kandlbinder 2023-02-24 22:17:45 +01:00
commit 15407746e3
37 changed files with 8525 additions and 0 deletions

8
graph/model/calendar.go Normal file
View file

@ -0,0 +1,8 @@
package model
type Calendar struct {
ID string `json:"id"`
DbID uint64
Name string `json:"name"`
Description string `json:"description"`
}

46
graph/model/converters.go Normal file
View file

@ -0,0 +1,46 @@
package model
import (
"github.com/Unkn0wnCat/calapi/internal/db_model"
"strconv"
)
func FromEvent(event db_model.Event) Event {
modelEvent := Event{
ID: strconv.FormatUint(event.Id, 16),
Title: event.Title,
Location: nil,
Description: event.Description,
Start: event.Start,
End: event.End,
DbCalendar: event.Calendar,
}
if (event.LocationLat != 0 && event.LocationLon != 0) || event.LocationName != "" || event.LocationAddr != "" {
modelEvent.Location = &Location{}
if event.LocationLat != 0 && event.LocationLon != 0 {
modelEvent.Location.Lat = &event.LocationLat
modelEvent.Location.Lon = &event.LocationLon
}
if event.LocationName != "" {
modelEvent.Location.Name = &event.LocationName
}
if event.LocationAddr != "" {
modelEvent.Location.Address = &event.LocationAddr
}
}
return modelEvent
}
func FromCalendar(calendar db_model.Calendar) Calendar {
return Calendar{
ID: strconv.FormatUint(calendar.Id, 16),
DbID: calendar.Id,
Name: calendar.Name,
Description: calendar.Description,
}
}

16
graph/model/event.go Normal file
View file

@ -0,0 +1,16 @@
package model
import (
"github.com/Unkn0wnCat/calapi/internal/db_model"
"time"
)
type Event struct {
ID string `json:"id"`
Title string `json:"title"`
Location *Location `json:"location"`
Description string `json:"description"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
DbCalendar *db_model.Calendar
}

55
graph/model/models_gen.go Normal file
View file

@ -0,0 +1,55 @@
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package model
import (
"time"
)
type EditCalendar struct {
Name *string `json:"name"`
Description *string `json:"description"`
}
type EditEvent struct {
ID string `json:"id"`
Title *string `json:"title"`
Location *SetLocation `json:"location"`
Description *string `json:"description"`
Start *time.Time `json:"start"`
End *time.Time `json:"end"`
Calendar *string `json:"calendar"`
}
type Location struct {
Lat *float64 `json:"lat"`
Lon *float64 `json:"lon"`
Name *string `json:"name"`
Address *string `json:"address"`
}
type NewCalendar struct {
Name string `json:"name"`
Description string `json:"description"`
}
type NewEvent struct {
Title string `json:"title"`
Location *SetLocation `json:"location"`
Description string `json:"description"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
Calendar string `json:"calendar"`
}
type SetLocation struct {
Lat *float64 `json:"lat"`
Lon *float64 `json:"lon"`
Name *string `json:"name"`
Address *string `json:"address"`
}
type User struct {
ID string `json:"id"`
Name string `json:"name"`
}