yaac_backend_database

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_ORDER = "ReceivedAt DESC"

Variables

This section is empty.

Functions

This section is empty.

Types

type Attendance

type Attendance struct {
	StudentID        uint `gorm:"primaryKey"`
	AttendanceListID uint `gorm:"primaryKey"` //`gorm:"primaryKey;foreignKey:Id;references:AttendanceList"`
	IsAttending      bool
	NameROI          Rectangle
	SignatureROI     Rectangle
	TotalROI         Rectangle
}

type AttendanceList

type AttendanceList struct {
	ID uint `gorm:"primaryKey"`
	// CreatedAt is a primary key to ensure, that only one list per day can exist
	CreatedAt    time.Time `gorm:"primaryKey"`
	UpdatedAt    time.Time
	CourseID     uint //`gorm:"foreignKey:Id;references:Course"`
	ReceivedAt   time.Time
	Attendancies []Attendance
	Image        []byte // image as png
}

type BackendDatabase

type BackendDatabase struct {
	MVVM mvvm
	Path string
	DB   *gorm.DB
}

func NewBackend

func NewBackend(mvvm mvvm, path string) *BackendDatabase

func (*BackendDatabase) AllAttendanceListInRange

func (item *BackendDatabase) AllAttendanceListInRange(start time.Time, end time.Time) ([]AttendanceList, error)

Get all attendance lists for aall courses in a time range.

[start, end)

func (*BackendDatabase) AllAttendanceListInRangeByCourse

func (item *BackendDatabase) AllAttendanceListInRangeByCourse(course Course, start time.Time, end time.Time) ([]AttendanceList, error)

Get all attendance lists for a course in a time range.

[start, end)

func (*BackendDatabase) ConnectDatabase

func (item *BackendDatabase) ConnectDatabase() error

Ensure that the database is present and all tables being there

func (*BackendDatabase) CourseByName

func (item *BackendDatabase) CourseByName(name string) (Course, error)

Get a course by name.

func (*BackendDatabase) CourseStudents

func (item *BackendDatabase) CourseStudents(course Course) ([]Student, error)

Get all students in a `course`.

func (*BackendDatabase) Courses

func (item *BackendDatabase) Courses() ([]Course, error)

Get all courses saved in the database.

func (*BackendDatabase) InsertCourse

func (item *BackendDatabase) InsertCourse(course Course) (Course, error)

Insert a new course. It is not checked whether the course already exists.

func (*BackendDatabase) InsertList

func (item *BackendDatabase) InsertList(list AttendanceList) (AttendanceList, error)

This function allows only one list per day. If a list already exists, it overwrites it. AttendanceList must be filled out fully, except the ID.

func (*BackendDatabase) InsertStudent

func (item *BackendDatabase) InsertStudent(student Student) (Student, error)

Add a new student to the database. student.FullName will be set automatically.

func (*BackendDatabase) LatestList

func (item *BackendDatabase) LatestList(course Course, end time.Time) (AttendanceList, error)

Get the latest list before a certain date for a course [..., end)

func (*BackendDatabase) Settings

func (item *BackendDatabase) Settings() ([]Setting, error)

Get all settings saved in the database

func (*BackendDatabase) SettingsReset

func (item *BackendDatabase) SettingsReset() ([]Setting, error)

Reset all settings. This clears the `Setting` table

func (*BackendDatabase) SettingsUpdate

func (item *BackendDatabase) SettingsUpdate(settings []Setting) ([]Setting, error)

Update settings. `settings` need not contain all key-value pairs.

func (*BackendDatabase) Students

func (item *BackendDatabase) Students(student Student) ([]Student, error)

func (*BackendDatabase) UpdateList

func (item *BackendDatabase) UpdateList(list AttendanceList) (AttendanceList, error)

`list` needs the field `Id` to be not null.

type Course

type Course struct {
	gorm.Model
	Name     string `gorm:"unique"`
	Students []Student
}

type Rectangle

type Rectangle image.Rectangle

func (*Rectangle) Scan

func (rect *Rectangle) Scan(value any) error

func (Rectangle) Value

func (rect Rectangle) Value() (driver.Value, error)

type Setting

type Setting struct {
	Setting string `gorm:"primaryKey"`
	Value   string
}

type Student

type Student struct {
	gorm.Model
	FirstName        string `gorm:"check:FirstName!='';type:varchar(64)"`
	LastName         string `gorm:"check:LastName!='';type:varchar(64)"`
	FullName         string `gorm:"check:FullName!='';type:varchar(128);uniqueIndex:namecourseunique;index;not null"`
	CourseID         uint   `gorm:"uniqueIndex:namecourseunique;not null"`
	IsImmatriculated bool   `gorm:"default:true"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL