feat: updated docs and added description to files
This commit is contained in:
@@ -1,8 +1,19 @@
|
||||
// the models package contains the datamodels for the whole webserver
|
||||
// most of them are also in the DB
|
||||
//
|
||||
// in the future it would be good to change it to create a repository structure,
|
||||
// so that there would be a second pacakge handling db requests
|
||||
|
||||
package models
|
||||
|
||||
// this file has all functions and types to handle absences
|
||||
// the absence type implements the iWorkDay interface so that
|
||||
// it can be used as one workday
|
||||
//
|
||||
// the absence data is based on the entries in the "abwesenheit" database table
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
@@ -27,25 +38,6 @@ func (a *Absence) IsEmpty() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func NewAbsence(card_uid string, abwesenheit_typ int, datum time.Time) (Absence, error) {
|
||||
if abwesenheit_typ < 0 {
|
||||
return Absence{
|
||||
CardUID: card_uid,
|
||||
AbwesenheitTyp: AbsenceType{0, "Custom absence", 100},
|
||||
DateFrom: datum,
|
||||
}, nil
|
||||
}
|
||||
_absenceType, ok := GetAbsenceTypesCached()[int8(abwesenheit_typ)]
|
||||
if !ok {
|
||||
return Absence{}, errors.New("Invalid absencetype")
|
||||
}
|
||||
return Absence{
|
||||
CardUID: card_uid,
|
||||
AbwesenheitTyp: _absenceType,
|
||||
DateFrom: datum,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a *Absence) Date() time.Time {
|
||||
return a.Day.Truncate(24 * time.Hour)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user