mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2025-08-03 10:19:16 +02:00
added frontend and updated backend with docker, wrote some initial instructions
This commit is contained in:
12
backend/service/events/courseService.go
Normal file
12
backend/service/events/courseService.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package events
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v5"
|
||||
"github.com/pocketbase/pocketbase"
|
||||
"htwk-planner/service/db"
|
||||
)
|
||||
|
||||
func GetAllCourses(app *pocketbase.PocketBase, c echo.Context) error {
|
||||
courses := db.GetAllCourses(app)
|
||||
return c.JSON(200, courses)
|
||||
}
|
63
backend/service/events/eventService.go
Normal file
63
backend/service/events/eventService.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package events
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v5"
|
||||
"github.com/pocketbase/pocketbase"
|
||||
"htwk-planner/service/db"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
func GetModulesForCourseDistinct(app *pocketbase.PocketBase, c echo.Context, course string, semester string) error {
|
||||
|
||||
modules, err := db.GetAllModulesForCourse(app, course, semester)
|
||||
replaceEmptyEntryInStringArray(modules, "Sonderveranstaltungen")
|
||||
|
||||
if err != nil {
|
||||
return c.JSON(400, err)
|
||||
} else {
|
||||
return c.JSON(200, modules)
|
||||
}
|
||||
}
|
||||
|
||||
func replaceEmptyEntryInStringArray(modules []string, replacement string) {
|
||||
//replace empty string with "Sonderveranstaltungen"
|
||||
for i, module := range modules {
|
||||
if checkIfOnlyWhitespace(module) {
|
||||
modules[i] = replacement
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func replaceEmptyEntry(modules []struct {
|
||||
Name string
|
||||
Course string
|
||||
}, replacement string) {
|
||||
//replace empty string with "Sonderveranstaltungen"
|
||||
for i, module := range modules {
|
||||
if checkIfOnlyWhitespace(module.Name) {
|
||||
modules[i].Name = replacement
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if course is empty or contains only whitespaces
|
||||
func checkIfOnlyWhitespace(word string) bool {
|
||||
for _, letter := range word {
|
||||
if !unicode.IsSpace(letter) || !(letter == int32(160)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func GetAllModulesDistinct(app *pocketbase.PocketBase, c echo.Context) error {
|
||||
modules, err := db.GetAllModulesDistinct(app)
|
||||
|
||||
replaceEmptyEntry(modules, "Sonderveranstaltungen")
|
||||
|
||||
if err != nil {
|
||||
return c.JSON(400, err)
|
||||
} else {
|
||||
return c.JSON(200, modules)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user