sql

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

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

Go to latest
Published: Feb 23, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const COMMIT_HASH = ""

Variables

This section is empty.

Functions

func CheckHash

func CheckHash(pass string, hashedPass string) bool

func HashPassword

func HashPassword(pass string) (string, error)

func SaveConfig

func SaveConfig(config Config) error

Types

type Absence

type Absence struct {
	ID          string
	UserID      string `db:"user_id"`
	TeacherID   string `db:"teacher_id"`
	MeetingID   string `db:"meeting_id"`
	AbsenceType string `db:"absence_type"`
	IsExcused   bool   `db:"is_excused"`

	CreatedAt string `db:"created_at"`
	UpdatedAt string `db:"updated_at"`
}

type Class

type Class struct {
	ID             string
	Name           string
	Teacher        string
	Students       string
	ClassYear      string `db:"class_year"`
	SOK            int
	EOK            int
	LastSchoolDate int `db:"last_school_date"`

	CreatedAt string `db:"created_at"`
	UpdatedAt string `db:"updated_at"`
}

type Communication

type Communication struct {
	ID          string
	People      string
	DateCreated string `db:"date_created"`
	Title       string

	CreatedAt string `db:"created_at"`
	UpdatedAt string `db:"updated_at"`
}

type Config

type Config struct {
	DatabaseName       string   `json:"database_name"`
	DatabaseConfig     string   `json:"database_config"`
	Debug              bool     `json:"debug"`
	Host               string   `json:"host"`
	CommitHash         string   `json:"commit_hash"`
	RemoteRepository   string   `json:"remote_repository"`
	SchoolName         string   `json:"school_name"`
	SchoolAddress      string   `json:"school_address"`
	SchoolCity         string   `json:"school_city"`
	SchoolCountry      string   `json:"school_country"`
	SchoolPostCode     int      `json:"school_post_code"`
	ParentViewGrades   bool     `json:"parent_view_grades"`
	ParentViewAbsences bool     `json:"parent_view_absences"`
	ParentViewHomework bool     `json:"parent_view_homework"`
	ParentViewGradings bool     `json:"parent_view_gradings"`
	BlockRegistrations bool     `json:"block_registrations"`
	BlockMeals         bool     `json:"block_meals"`
	SchoolFreeDays     []string `json:"school_free_days"`
}

func GetConfig

func GetConfig() (Config, error)

type Document

type Document struct {
	ID           string
	ExportedBy   string `db:"exported_by"`
	DocumentType int    `db:"document_type"`
	Timestamp    string `db:"created_at"`
	IsSigned     bool   `db:"is_signed"`
	UpdatedAt    string `db:"updated_at"`
}

type Grade

type Grade struct {
	ID          string
	UserID      string `db:"user_id"`
	TeacherID   string `db:"teacher_id"`
	SubjectID   string `db:"subject_id"`
	Grade       int
	Date        string
	IsWritten   bool `db:"is_written"`
	IsFinal     bool `db:"is_final"`
	Period      int
	Description string
	CanPatch    bool `db:"can_patch"`

	CreatedAt string `db:"created_at"`
	UpdatedAt string `db:"updated_at"`
}

type Homework

type Homework struct {
	ID          string
	TeacherID   string `db:"teacher_id"`
	SubjectID   string `db:"subject_id"`
	Name        string
	Description string
	ToDate      string `db:"to_date"`
	FromDate    string `db:"from_date"`

	CreatedAt string `db:"created_at"`
	UpdatedAt string `db:"updated_at"`
}

type Improvement

type Improvement struct {
	ID        string
	StudentID string `db:"student_id"`
	MeetingID string `db:"meeting_id"`
	TeacherID string `db:"teacher_id"`
	Message   string

	CreatedAt string `db:"created_at"`
	UpdatedAt string `db:"updated_at"`
}

type Meal

type Meal struct {
	ID            string
	Meals         string
	Date          string
	MealTitle     string `db:"meal_title"`
	Price         float32
	Orders        string
	IsLimited     bool `db:"is_limited"`
	OrderLimit    int  `db:"order_limit"`
	IsVegan       bool `db:"is_vegan"`
	IsVegetarian  bool `db:"is_vegetarian"`
	IsLactoseFree bool `db:"is_lactose_free"`
	BlockOrders   bool `db:"block_orders"`

	CreatedAt string `db:"created_at"`
	UpdatedAt string `db:"updated_at"`
}

type Meeting

type Meeting struct {
	ID             string `db:"id"`
	MeetingName    string `db:"meeting_name"`
	TeacherID      string `db:"teacher_id"`
	SubjectID      string `db:"subject_id"`
	Hour           int    `db:"hour"`
	Date           string `db:"date"`
	IsMandatory    bool   `db:"is_mandatory"`
	URL            string `db:"url"`
	Details        string `db:"details"`
	IsSubstitution bool   `db:"is_substitution"`
	Location       string `db:"location"`
	// Ocenjevanje
	IsGrading           bool `db:"is_grading"`
	IsWrittenAssessment bool `db:"is_written_assessment"`
	IsCorrectionTest    bool `db:"is_correction_test"`
	// Preverjanje znanja
	IsTest bool `db:"is_test"`
	// Beta srečanja so tista, ustvarjena s Proton layerjem. Proton bo prvo ustvaril nova beta srečanja, ki so neodvisna od drugih in katerih učenci ne morejo videti.
	// Vsak učitelj bo lahko preveril svoje učne ure in svoj urnik s tem ustvarjenim urnikom.
	// Če učitelji ne bodo zadovoljni, se z enim klikom izbriše ta srečanja in se ustvari nov urnik s Proton layerjem, drugače pa se jih z enim klikom spremeni v normalna srečanja,
	// vidna tudi učencem
	IsBeta bool `db:"is_beta"`

	CreatedAt string `db:"created_at"`
	UpdatedAt string `db:"updated_at"`
}

type Message

type Message struct {
	ID              string
	CommunicationID string `db:"communication_id"`
	UserID          string `db:"user_id"`
	Body            string
	Seen            string
	DateCreated     string `db:"date_created"`

	CreatedAt string `db:"created_at"`
	UpdatedAt string `db:"updated_at"`
}

type NotificationSQL

type NotificationSQL struct {
	ID           string
	Notification string

	CreatedAt string `db:"created_at"`
	UpdatedAt string `db:"updated_at"`
}

type SQL

type SQL interface {
	CheckToken(loginToken string) (User, error)
	GetRandomToken(currentUser User) (string, error)

	Init()
	Exec(query string) error

	UpdateTestingResult(testing Testing) error
	InsertTestingResult(testing Testing) error
	GetTestingResults(date string, classId string) ([]TestingJSON, error)
	GetAllTestingsForUser(id string) (testing []Testing, err error)
	GetTestingResult(date string, id string) (Testing, error)
	GetTestingResultByID(id string) (Testing, error)

	DeleteTeacherSelfTesting(teacherId string) error
	DeleteUserSelfTesting(userId string) error

	GetUser(id string) (user User, err error)
	GetUserByLoginToken(loginToken string) (user User, err error)
	InsertUser(user User) (err error)

	GetUserByEmail(email string) (user User, err error)
	CheckIfAdminIsCreated() bool
	GetAllUsers() (users []User, err error)
	UpdateUser(user User) error
	DeleteUser(ID string) error
	GetTeachers() ([]User, error)
	GetPrincipal() (principal User, err error)

	GetClass(id string) (Class, error)
	InsertClass(class Class) (err error)

	UpdateClass(class Class) error
	GetClasses() ([]Class, error)
	DeleteClass(ID string) error
	DeleteTeacherClasses(teacherId string) error
	DeleteUserClasses(userId string)

	GetMeeting(id string) (meeting Meeting, err error)
	GetMeetingsOnSpecificTime(date string, hour int) (meetings []Meeting, err error)
	GetMeetingsForSubject(subjectId string) (meetings []Meeting, err error)
	GetMeetingsForTeacherOnSpecificDate(teacherId string, date string) (meetings []Meeting, err error)
	InsertMeeting(meeting Meeting) (err error)
	UpdateMeeting(meeting Meeting) error

	GetMeetings() (meetings []Meeting, err error)
	GetMeetingsForSubjectWithIDLower(createdAt string, subjectId string) (meetings []Meeting, err error)
	DeleteMeeting(ID string) error
	GetMeetingsOnSpecificDate(date string, includeBeta bool) (meetings []Meeting, err error)
	DeleteMeetingsForTeacher(ID string) error
	DeleteMeetingsForSubject(ID string) error
	MigrateBetaMeetingsToNonBeta() error
	DeleteBetaMeetings() error

	GetAbsence(id string) (absence Absence, err error)
	GetAllAbsences(id string) (absences []Absence, err error)
	InsertAbsence(absence Absence) error
	UpdateAbsence(absence Absence) error
	GetAbsenceForUserMeeting(meeting_id string, user_id string) (absence Absence, err error)
	GetAbsencesForUser(user_id string) (absence []Absence, err error)
	DeleteAbsencesForTeacher(userId string)
	DeleteAbsencesForUser(userId string)

	GetSubject(id string) (subject Subject, err error)
	GetAllSubjectsForTeacher(id string) (subject []Subject, err error)
	GetAllSubjectsForUser(id string) (subject []Subject, err error)
	GetSubjectsWithSpecificLongName(longName string) (subject []Subject, err error)
	InsertSubject(subject Subject) error
	UpdateSubject(subject Subject) error
	GetAllSubjects() (subject []Subject, err error)
	GetStudents() (message []User, err error)
	DeleteSubject(subject Subject) error
	DeleteStudentSubject(userId string)

	GetGrade(id string) (grade Grade, err error)
	GetGradesForUser(userId string) (grades []Grade, err error)
	GetGradesForUserInSubject(userId string, subjectId string) (grades []Grade, err error)
	CheckIfFinal(userId string, subjectId string) (grade Grade, err error)
	InsertGrade(grade Grade) error
	UpdateGrade(grade Grade) error
	DeleteGrade(ID string) error
	DeleteGradesByTeacherID(ID string) error
	DeleteGradesByUserID(ID string) error

	GetHomework(id string) (homework Homework, err error)
	GetHomeworkForSubject(id string) (homework []Homework, err error)
	InsertHomework(homework Homework) error
	UpdateHomework(homework Homework) error
	DeleteHomework(ID string) error

	GetStudentHomework(id string) (homework StudentHomework, err error)
	GetStudentHomeworkForUser(homeworkId string, userId string) (homework StudentHomework, err error)
	DeleteStudentHomeworkByStudentID(ID string) error
	GetHomeworkForTeacher(teacherId string) (homework []Homework, err error)
	GetStudentsHomeworkByHomeworkID(id string, meetingId string) (homework []StudentHomeworkJSON, err error)
	GetStudentsHomework(id string) (homework []StudentHomework, err error)
	InsertStudentHomework(homework StudentHomework) error
	UpdateStudentHomework(homework StudentHomework) error
	DeleteStudentHomework(ID string) error
	DeleteStudentHomeworkByHomeworkID(ID string) error
	DeleteAllTeacherHomeworks(ID string)

	GetCommunication(id string) (communication Communication, err error)
	InsertCommunication(communication Communication) (err error)
	UpdateCommunication(communication Communication) error

	GetCommunications() (communication []Communication, err error)
	DeleteCommunication(ID string) error
	DeleteUserCommunications(userId string)

	GetMessage(id string) (message Message, err error)
	GetCommunicationMessages(communicationId string) (messages []Message, err error)
	GetAllUnreadMessages(userId string) (messages []Message, err error)
	InsertMessage(message Message) (err error)
	UpdateMessage(message Message) error

	GetAllMessages() (messages []Message, err error)
	DeleteMessage(ID string) error

	GetMeal(id string) (meal Meal, err error)
	InsertMeal(meal Meal) (err error)
	UpdateMeal(meal Meal) error

	GetMeals() (meals []Meal, err error)
	DeleteMeal(ID string) error

	GetNotification(id string) (notification NotificationSQL, err error)
	GetAllNotifications() (notifications []NotificationSQL, err error)
	InsertNotification(notification NotificationSQL) (err error)
	UpdateNotification(notification NotificationSQL) error

	DeleteNotification(ID string) error

	GetImprovement(id string) (improvement Improvement, err error)
	GetImprovementsForStudent(studentId string) (improvements []Improvement, err error)
	InsertImprovement(improvement Improvement) error
	UpdateImprovement(homework Homework) error
	DeleteImprovement(ID string) error

	GetDocument(id string) (document Document, err error)
	GetAllDocuments() (documents []Document, err error)
	InsertDocument(document Document) error
	DeleteDocument(id string)
}

func NewSQL

func NewSQL(driver string, drivername string, logger *zap.SugaredLogger) (SQL, error)

type StudentHomework

type StudentHomework struct {
	ID         string
	UserID     string `db:"user_id"`
	HomeworkID string `db:"homework_id"`
	Status     string

	CreatedAt string `db:"created_at"`
	UpdatedAt string `db:"updated_at"`
}

type StudentHomeworkJSON

type StudentHomeworkJSON struct {
	StudentHomework
	Name        string
	TeacherName string
}

type Subject

type Subject struct {
	ID            string
	TeacherID     string `db:"teacher_id"`
	Name          string
	InheritsClass bool    `db:"inherits_class"`
	ClassID       *string `db:"class_id"`
	Students      string
	LongName      string `db:"long_name"`
	Realization   float32
	SelectedHours float32 `db:"selected_hours"`
	Color         string
	Location      string `db:"location"`
	IsGraded      bool   `db:"is_graded"`

	CreatedAt string `db:"created_at"`
	UpdatedAt string `db:"updated_at"`
}

type Testing

type Testing struct {
	ID        string
	UserID    string `db:"user_id"`
	Date      string
	TeacherID string `db:"teacher_id"`
	ClassID   string `db:"class_id"`
	Result    string

	CreatedAt string `db:"created_at"`
	UpdatedAt string `db:"updated_at"`
}

type TestingJSON

type TestingJSON struct {
	ID          string
	UserID      string `db:"user_id"`
	Date        string
	TeacherID   string `db:"teacher_id"`
	TeacherName string
	ClassID     string `db:"class_id"`
	ValidUntil  string
	Result      string
	IsDone      bool
	UserName    string
}

type User

type User struct {
	ID                     string
	Email                  string
	Password               string `db:"pass"`
	Role                   string
	Name                   string
	BirthCertificateNumber string `db:"birth_certificate_number"`
	Birthday               string
	CityOfBirth            string `db:"city_of_birth"`
	CountryOfBirth         string `db:"country_of_birth"`
	Users                  string
	LoginToken             string `db:"login_token"`
	IsPassing              bool   `db:"is_passing"`
	IsLocked               bool   `db:"is_locked"`

	CreatedAt string `db:"created_at"`
	UpdatedAt string `db:"updated_at"`
}

Jump to

Keyboard shortcuts

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