service

package
v0.0.0-...-84b44bb Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package service wraps user interfaces with common logic unrelated to any particular user implementation. All consumers should be using service.DataStore and not the naked repositories!

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataStore

type DataStore struct {
	UserRepository    user.Interface
	TeacherRepository teacher.Interface
	UniOrgRepository  uni.Interface
	SchedRepository   sched.Interface
	BCryptCost        int
}

DataStore wraps all stores with common and additional methods todo looks ugly, rewrite

func (*DataStore) AddClasses

func (s *DataStore) AddClasses(classes []store.Class) error

AddClasses to the database

func (*DataStore) AddCourse

func (s *DataStore) AddCourse(course store.Course) (id string, err error)

AddCourse to the database

func (*DataStore) AddGroup

func (s *DataStore) AddGroup(name string, studyYearID string) (id string, err error)

AddGroup to the database

func (*DataStore) AddStudyYear

func (s *DataStore) AddStudyYear(name string) (id string, err error)

AddStudyYear to the database

func (*DataStore) AddTeacher

func (s *DataStore) AddTeacher(teacher store.Teacher) (teacherID string, err error)

AddTeacher to the database

func (*DataStore) AddUser

func (s *DataStore) AddUser(user store.User, password string) (id string, err error)

AddUser to the database, hash its password and give it an ID, if needed

func (*DataStore) CheckUserCredentials

func (s *DataStore) CheckUserCredentials(email string, password string) (ok bool, err error)

CheckUserCredentials with the given username and password

func (*DataStore) DeleteGroup

func (s *DataStore) DeleteGroup(id string) error

DeleteGroup from the database

func (*DataStore) DeleteStudyYear

func (s *DataStore) DeleteStudyYear(studyYearID string) error

DeleteStudyYear by its id

func (*DataStore) DeleteTeacher

func (s *DataStore) DeleteTeacher(teacherID string) error

DeleteTeacher from the database by its id

func (*DataStore) GetCourse

func (s *DataStore) GetCourse(id string) (store.Course, error)

GetCourse by id

func (*DataStore) GetGroup

func (s *DataStore) GetGroup(id string) (store.Group, error)

GetGroup from the database

func (*DataStore) GetStudyYear

func (s *DataStore) GetStudyYear(id string) (sy store.StudyYear, err error)

GetStudyYear by its id

func (*DataStore) GetTeacherFull

func (s *DataStore) GetTeacherFull(teacherID string) (store.Teacher, error)

GetTeacherFull returns all data about the requested teacher, including teacher preferences

func (*DataStore) GetUserEmail

func (s *DataStore) GetUserEmail(id string) (email string, err error)

GetUserEmail returns the email of the specified user

func (*DataStore) GetUserPrivs

func (s *DataStore) GetUserPrivs(id string) (privs []store.Privilege, err error)

GetUserPrivs returns the list of privileges of the specified user

func (*DataStore) ListClasses

func (s *DataStore) ListClasses(from time.Time, till time.Time, groupID string) ([]store.Class, error)

ListClasses in the given period for the given group

func (*DataStore) ListCourses

func (s *DataStore) ListCourses() (res []store.Course, err error)

ListCourses that are registered in the database

func (*DataStore) ListGroups

func (s *DataStore) ListGroups() ([]store.Group, error)

ListGroups registered in the database

func (*DataStore) ListStudyYears

func (s *DataStore) ListStudyYears() ([]store.StudyYear, error)

ListStudyYears that are registered in the database

func (*DataStore) ListTeachers

func (s *DataStore) ListTeachers() ([]store.TeacherDetails, error)

ListTeachers returns all teachers that are registered in the database

func (*DataStore) ListTimeSlots

func (s *DataStore) ListTimeSlots() ([]store.TimeSlot, error)

ListTimeSlots that are registered in the database

func (*DataStore) RegisterAdmin

func (s *DataStore) RegisterAdmin(email string, password string) (id string, err error)

RegisterAdmin in the database

func (*DataStore) SetTeacherPreferences

func (s *DataStore) SetTeacherPreferences(teacherID string, pref store.TeacherPreferences) error

SetTeacherPreferences sets preferences for the given teacher

Jump to

Keyboard shortcuts

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