getUserName path implemented

This commit is contained in:
Imbus 2024-04-04 19:54:31 +02:00
parent db6fdf3c29
commit abfb79b991
4 changed files with 67 additions and 0 deletions

View file

@ -44,6 +44,7 @@ type Database interface {
GetProjectTimes(projectName string) (map[string]int, error)
UpdateWeeklyReport(projectName string, userName string, week int, developmentTime int, meetingTime int, adminTime int, ownWorkTime int, studyTime int, testingTime int) error
RemoveProject(projectname string) error
GetUserName(id int) (string, error)
}
// This struct is a wrapper type that holds the database connection
@ -611,3 +612,9 @@ func (d *Db) RemoveProject(projectname string) error {
_, err := d.Exec("DELETE FROM projects WHERE name = ?", projectname)
return err
}
func (d *Db) GetUserName(id int) (string, error) {
var username string
err := d.Get(&username, "SELECT username FROM users WHERE id = ?", id)
return username, err
}