Verbessere Dokumentation
This commit is contained in:
parent
ec24c6c4dc
commit
fe54d76ab2
14 changed files with 75 additions and 34 deletions
|
@ -1,4 +1,3 @@
|
|||
// course
|
||||
package models
|
||||
|
||||
type Course struct {
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
// date
|
||||
package models
|
||||
|
||||
import (
|
||||
"log"
|
||||
)
|
||||
|
||||
type Date struct {
|
||||
Week int
|
||||
Week int // Set whether the date is all weeks (0), odd weeks (1) or even weeks (2).
|
||||
Day int
|
||||
Hour int
|
||||
Minute int
|
||||
}
|
||||
|
||||
// Return the name of the day for a given integer.
|
||||
func DayName(day int) string {
|
||||
switch day {
|
||||
case 0:
|
||||
|
@ -21,10 +25,12 @@ func DayName(day int) string {
|
|||
case 4:
|
||||
return "Freitag"
|
||||
default:
|
||||
log.Printf("No day name found for day %d", day)
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// Compare whether first date is strictly before second date.
|
||||
func DateLess(first Date, second Date) bool {
|
||||
if first.Day < second.Day {
|
||||
return true
|
||||
|
@ -44,6 +50,7 @@ func DateLess(first Date, second Date) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// Get the end date for some duration.
|
||||
func GetEndDate(date Date, duration int, ignoreWeek bool) Date {
|
||||
var endDate Date
|
||||
if ignoreWeek {
|
||||
|
@ -51,6 +58,7 @@ func GetEndDate(date Date, duration int, ignoreWeek bool) Date {
|
|||
} else {
|
||||
endDate = Date{date.Week, date.Day, date.Hour, date.Minute}
|
||||
}
|
||||
endDate.Day = (endDate.Day + (endDate.Hour*60+endDate.Minute+duration)/(60*24)) % 7
|
||||
endDate.Hour = endDate.Hour + (endDate.Minute+duration)/60
|
||||
endDate.Minute = (endDate.Minute + duration) % 60
|
||||
return endDate
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// officeHour
|
||||
// The package models defines the stucts for objects, their repositories and the signatures of their functions.
|
||||
package models
|
||||
|
||||
type OfficeHour struct {
|
||||
|
@ -7,10 +7,10 @@ type OfficeHour struct {
|
|||
Date
|
||||
Room
|
||||
Course
|
||||
RoomName string
|
||||
RoomName string // A description of the room for special rooms that are not preconfigured.
|
||||
Info string
|
||||
Active bool
|
||||
Duration int
|
||||
Duration int // Duration in minutes. Must be divisible by the config field "MinuteGranularity".
|
||||
}
|
||||
|
||||
type OfficeHourRepository interface {
|
||||
|
|
|
@ -8,8 +8,8 @@ type Request struct {
|
|||
Secret string
|
||||
}
|
||||
|
||||
const RequestActivate int = 1
|
||||
const RequestDelete int = 2
|
||||
const RequestActivate int = 1 // Fix integer to represent request for activation of an office hour.
|
||||
const RequestDelete int = 2 // Fix integer to represent request for deletion of an office hour.
|
||||
|
||||
type RequestRepository interface {
|
||||
Add(officeHour OfficeHour, action int) (int, error)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// raum
|
||||
package models
|
||||
|
||||
type Room struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue