refactor: change template generation from go-elem to templ and clean up the repository
This commit is contained in:
parent
f6b6f81826
commit
a3dc4eddfa
19 changed files with 842 additions and 874 deletions
64
utils/utils.go
Normal file
64
utils/utils.go
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"echoTest/models"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func SetNote(prozent float64) float64 {
|
||||
switch {
|
||||
case prozent <= 22:
|
||||
return 6.00
|
||||
case prozent <= 49:
|
||||
return 5.00
|
||||
case prozent <= 64:
|
||||
return 4.00
|
||||
case prozent <= 79:
|
||||
return 3.00
|
||||
case prozent <= 94:
|
||||
return 2.00
|
||||
default:
|
||||
return 1.00
|
||||
}
|
||||
}
|
||||
|
||||
func CheckGewichtung(lv, hv float64) bool {
|
||||
if hv/100+lv/100 > 1 {
|
||||
return false
|
||||
} else if hv/100+lv/100 < 1 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func OpenInBrowser(url string) {
|
||||
var cmd *exec.Cmd
|
||||
switch os := runtime.GOOS; os {
|
||||
case "darwin":
|
||||
cmd = exec.Command("open", url)
|
||||
case "windows":
|
||||
cmd = exec.Command("cmd", "/c", "start", url)
|
||||
default:
|
||||
cmd = exec.Command("xdg-open", url)
|
||||
}
|
||||
err := cmd.Start()
|
||||
if err != nil {
|
||||
fmt.Println("Fehler beim Öffnen des Browsers:", err)
|
||||
}
|
||||
}
|
||||
|
||||
func ValidateName(c echo.Context, bewertungen *[]models.Bewertung) string {
|
||||
newNachname := c.FormValue("nachname")
|
||||
newVorname := c.FormValue("vorname")
|
||||
for _, bewertung := range *bewertungen {
|
||||
fmt.Printf("Name: %v", bewertung.Nachname)
|
||||
if bewertung.Nachname == newNachname && bewertung.Vorname == newVorname {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
return newNachname
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue