MySQL-Datenbank hinzugefügt und Abfrage korrigiert

This commit is contained in:
Gonne 2022-09-12 19:42:45 +02:00
parent e9e0cbf382
commit e89429c3c3
5 changed files with 49 additions and 12 deletions

View file

@ -119,16 +119,15 @@ func (r *OfficeHourRepo) Delete(officeHour models.OfficeHour) error {
func (r *OfficeHourRepo) getFromRow(row *sql.Row) (models.OfficeHour, error) {
var officeHour models.OfficeHour
var week, day, hour, minute, tutorid int
var roomName, courseName string
err := row.Scan(&officeHour.Id, &tutorid, &day, &hour, &minute, &roomName, &courseName, &week, &officeHour.Info, &officeHour.Active, &officeHour.Duration)
var week, day, hour, minute, tutorId, courseId, roomId int
err := row.Scan(&officeHour.Id, &tutorId, &day, &hour, &minute, &roomId, &courseId, &week, &officeHour.Info, &officeHour.Active, &officeHour.Duration)
if err != nil {
return models.OfficeHour{}, fmt.Errorf("Error getting single officeHours row from database: %s", err.Error())
}
officeHour.Date = models.Date{week, day, hour, minute}
officeHour.Room, _ = r.roomRepo.FindByName(roomName)
officeHour.Tutor, _ = r.tutorRepo.FindById(tutorid)
officeHour.Course, _ = r.courseRepo.FindByName(courseName)
officeHour.Room, _ = r.roomRepo.FindById(roomId)
officeHour.Tutor, _ = r.tutorRepo.FindById(tutorId)
officeHour.Course, _ = r.courseRepo.FindById(courseId)
return officeHour, nil
}

View file

@ -6,6 +6,7 @@ import (
"crypto/rand"
"database/sql"
"html/template"
"log"
"math/big"
"net/smtp"
"sprechstundentool/models"