2022-11-04 21:15:38 +01:00
|
|
|
// The package models defines the stucts for objects, their repositories and the signatures of their functions.
|
2022-08-29 22:58:19 +02:00
|
|
|
package models
|
|
|
|
|
|
|
|
type OfficeHour struct {
|
|
|
|
Id int
|
|
|
|
Tutor Tutor
|
|
|
|
Date
|
2022-09-27 16:40:47 +02:00
|
|
|
Room
|
|
|
|
Course
|
2022-11-04 21:15:38 +01:00
|
|
|
RoomName string // A description of the room for special rooms that are not preconfigured.
|
2022-08-29 22:58:19 +02:00
|
|
|
Info string
|
|
|
|
Active bool
|
2022-11-04 21:15:38 +01:00
|
|
|
Duration int // Duration in minutes. Must be divisible by the config field "MinuteGranularity".
|
2022-08-29 22:58:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type OfficeHourRepository interface {
|
|
|
|
FindById(id int) (OfficeHour, error)
|
2022-08-31 22:49:14 +02:00
|
|
|
FindByCourse(course Course, activeOnly bool) ([]OfficeHour, error)
|
|
|
|
FindByRoom(room Room, activatedOnly bool) ([]OfficeHour, error)
|
|
|
|
GetAll(activatedOnly bool) ([]OfficeHour, error)
|
2022-08-29 22:58:19 +02:00
|
|
|
Delete(officeHour OfficeHour) error
|
2022-09-05 17:55:08 +02:00
|
|
|
Add(officeHour OfficeHour) (int, error)
|
2022-09-07 18:26:05 +02:00
|
|
|
AllowedAt(date Date, duration int, room Room, activeOnly bool) (bool, error)
|
2022-08-29 22:58:19 +02:00
|
|
|
}
|
2022-09-07 21:48:40 +02:00
|
|
|
|
|
|
|
func (officeHour OfficeHour) EndDate() Date {
|
|
|
|
return GetEndDate(officeHour.Date, officeHour.Duration, false)
|
|
|
|
}
|