Fix swagger deps

This commit is contained in:
Florian Hoss 2023-07-04 23:18:05 +02:00
parent 28f068c890
commit f63210272d
28 changed files with 307 additions and 310 deletions

View file

@ -2,8 +2,6 @@ package controller
import (
"fmt"
"gitlab.unjx.de/flohoss/cafe-plaetschwiesle/internal/types"
)
type User struct {
@ -16,7 +14,7 @@ func (c *Controller) doesUserExist(username string) (User, error) {
var user User
result := c.orm.Limit(1).Find(&user, "username = ?", username)
if result.RowsAffected == 0 {
return user, fmt.Errorf(types.CannotFind.String())
return user, fmt.Errorf(CannotFind.String())
}
return user, nil
}
@ -25,7 +23,7 @@ func (c *Controller) getUserOrCreate(username string) (User, error) {
var user User
err := c.orm.Where(User{Username: username}).Attrs(User{ShowHotDrinks: true, ShowColdDrinks: true}).FirstOrCreate(&user).Error
if err != nil {
return user, fmt.Errorf(types.CannotCreate.String())
return user, fmt.Errorf(CannotCreate.String())
}
return user, nil
}
@ -36,7 +34,7 @@ func (c *Controller) updateUser(old *User, new *User) error {
"ShowColdDrinks": new.ShowColdDrinks,
"ShowHotDrinks": new.ShowHotDrinks}).Error
if err != nil {
return fmt.Errorf(types.CannotUpdate.String())
return fmt.Errorf(CannotUpdate.String())
}
return nil
}