mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-02 17:59:14 +02:00
feat:#150 rewrite error handling for routes
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package events
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v5"
|
||||
"github.com/pocketbase/pocketbase"
|
||||
"htwkalender/model"
|
||||
"htwkalender/service/db"
|
||||
@@ -40,21 +39,17 @@ func replaceEmptyEntry(namedList []Named, replacement string) {
|
||||
|
||||
// GetAllModulesDistinct returns all modules distinct by name and course from the database
|
||||
// That means you get all modules with duplicates if they have different courses
|
||||
func GetAllModulesDistinct(app *pocketbase.PocketBase, c echo.Context) error {
|
||||
func GetAllModulesDistinct(app *pocketbase.PocketBase) ([]model.ModuleDTO, error) {
|
||||
modules, err := db.GetAllModulesDistinctByNameAndCourse(app)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var namedModules []Named
|
||||
for _, module := range modules {
|
||||
namedModules = append(namedModules, &module)
|
||||
}
|
||||
|
||||
replaceEmptyEntry(namedModules, "Sonderveranstaltungen")
|
||||
|
||||
if err != nil {
|
||||
return c.JSON(400, err)
|
||||
} else {
|
||||
return c.JSON(200, modules)
|
||||
}
|
||||
return modules, nil
|
||||
}
|
||||
|
||||
func GetModuleByUUID(app *pocketbase.PocketBase, uuid string) (model.Module, error) {
|
||||
|
Reference in New Issue
Block a user