master
Evan Chen 2021-12-21 19:44:27 +08:00
parent 2f27f72450
commit 48b66258ea
5 changed files with 199 additions and 14 deletions

118
calendar/basic.ics Normal file
View File

@ -0,0 +1,118 @@
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:A301
X-WR-TIMEZONE:Asia/Taipei
X-WR-CALDESC:A301
BEGIN:VTIMEZONE
TZID:Asia/Taipei
X-LIC-LOCATION:Asia/Taipei
BEGIN:STANDARD
TZOFFSETFROM:+0800
TZOFFSETTO:+0800
TZNAME:CST
DTSTART:19700101T000000
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART:20211221T020000Z
DTEND:20211221T023000Z
DTSTAMP:20211221T113213Z
UID:60gh4s8m1m672d0l808cp0kq96@google.com
CREATED:20211221T113106Z
DESCRIPTION:edadlk123
LAST-MODIFIED:20211221T113106Z
LOCATION:T1-1
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:數學
TRANSP:TRANSPARENT
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=Asia/Taipei:20211104T102000
DTEND;TZID=Asia/Taipei:20211104T121500
RRULE:FREQ=WEEKLY;UNTIL=20211111T000000Z
DTSTAMP:20211221T113213Z
UID:ip9l2rk11sjr49sbhtcu0rrq7c@google.com
CREATED:20211102T063233Z
DESCRIPTION:{\n "name": "普通生物學乙"\,\n "teacher": "閔明源"\,\n "code":
"B01-101B0"\,\n "class": "01"\,\n "semester": "109-1"\,\n "locatio
n": "A301"\,\n "location_code": "a301"\n}
LAST-MODIFIED:20211102T063233Z
LOCATION:A301
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:普通生物學乙 閔明源
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=Asia/Taipei:20211102T132000
DTEND;TZID=Asia/Taipei:20211102T151500
RRULE:FREQ=WEEKLY;UNTIL=20211111T000000Z
DTSTAMP:20211221T113213Z
UID:elfaolrnjqeqogsc2cbum2kku0@google.com
CREATED:20211102T063232Z
DESCRIPTION:{\n "name": "普通生物學乙"\,\n "teacher": "閔明源"\,\n "code":
"B01-101B0"\,\n "class": "01"\,\n "semester": "109-1"\,\n "locatio
n": "A301"\,\n "location_code": "a301"\n}
LAST-MODIFIED:20211102T063232Z
LOCATION:A301
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:普通生物學乙 閔明源
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=Asia/Taipei:20211105T091000
DTEND;TZID=Asia/Taipei:20211105T100500
RRULE:FREQ=WEEKLY;UNTIL=20211111T000000Z
DTSTAMP:20211221T113213Z
UID:b6tqfns0oopvgvjtlvnca33j68@google.com
CREATED:20211102T063221Z
DESCRIPTION:{\n "name": "高等流體力學"\,\n "teacher": "謝之真"\,\n "code":
"524-M1210"\,\n "class": "02"\,\n "semester": "109-1"\,\n "locatio
n": "A301"\,\n "location_code": "a301"\n}
LAST-MODIFIED:20211102T063221Z
LOCATION:A301
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:高等流體力學 謝之真
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=Asia/Taipei:20211102T102000
DTEND;TZID=Asia/Taipei:20211102T121500
RRULE:FREQ=WEEKLY;UNTIL=20211111T000000Z
DTSTAMP:20211221T113213Z
UID:unnca2j62u7l561lupqga2tc40@google.com
CREATED:20211102T063220Z
DESCRIPTION:{\n "name": "高等流體力學"\,\n "teacher": "謝之真"\,\n "code":
"524-M1210"\,\n "class": "02"\,\n "semester": "109-1"\,\n "locatio
n": "A301"\,\n "location_code": "a301"\n}
LAST-MODIFIED:20211102T063221Z
LOCATION:A301
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:高等流體力學 謝之真
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=Asia/Taipei:20211104T142000
DTEND;TZID=Asia/Taipei:20211104T172500
RRULE:FREQ=WEEKLY;UNTIL=20211111T000000Z
DTSTAMP:20211221T113213Z
UID:paefk9l3jihei6hgocm65f72co@google.com
CREATED:20211102T063214Z
DESCRIPTION:{\n "name": "有限元素法"\,\n "teacher": "莊嘉揚"\,\n "code": "
522-M2570"\,\n "class": "0"\,\n "semester": "109-1"\,\n "location"
: "A301"\,\n "location_code": "a301"\n}
LAST-MODIFIED:20211102T063214Z
LOCATION:A301
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:有限元素法 莊嘉揚
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR

View File

@ -1,24 +1,27 @@
package calendar package calendar
import "time" import (
"time"
"github.com/rs/xid"
"github.com/rs/zerolog"
"gorm.io/gorm"
)
var l zerolog.Logger
type Calendar struct { type Calendar struct {
ID uint `gorm:"primaryKey"` ID string `gorm:"primaryKey"`
Events []Event
CreatedAt time.Time CreatedAt time.Time
UpdatedAt time.Time UpdatedAt time.Time
} }
type EventGroup struct { func (c *Calendar) BeforeCreate(tx *gorm.DB) (err error) {
ID uint `gorm:"primaryKey"` if c.ID == "" {
c.ID = xid.New().String()
CreatedAt time.Time
UpdatedAt time.Time
} }
return
type Event struct {
ID uint `gorm:"primaryKey"`
CreatedAt time.Time
UpdatedAt time.Time
} }

28
calendar/event.go Normal file
View File

@ -0,0 +1,28 @@
package calendar
import (
"time"
"github.com/rs/xid"
"gorm.io/gorm"
)
type Event struct {
ID string `gorm:"primaryKey"`
Start time.Time
End time.Time
CalendarID string
EventGroupID string
CreatedAt time.Time
UpdatedAt time.Time
}
func (e *Event) BeforeCreate(tx *gorm.DB) (err error) {
if e.ID == "" {
e.ID = xid.New().String()
}
return
}

24
calendar/event_group.go Normal file
View File

@ -0,0 +1,24 @@
package calendar
import (
"time"
"github.com/rs/xid"
"gorm.io/gorm"
)
type EventGroup struct {
ID string `gorm:"primaryKey"`
Events []Event
CreatedAt time.Time
UpdatedAt time.Time
}
func (eg *EventGroup) BeforeCreate(tx *gorm.DB) (err error) {
if eg.ID == "" {
eg.ID = xid.New().String()
}
return
}

12
calendar/service.go Normal file
View File

@ -0,0 +1,12 @@
package calendar
type Service struct{}
func (srv Service) GetName() string { return "calendar.Service" }
func (srv Service) GetDependencies() []string { return []string{} }
func (srv Service) IsService() bool { return false }
func (srv Service) Init() error { return nil }
func (srv Service) Load() error { return nil }
func (srv Service) Main() error { return nil }
func (srv Service) Del() {}
func (srv Service) Health() error { return nil }