diff --git a/models/status.go b/models/status.go index faf832f..a590083 100644 --- a/models/status.go +++ b/models/status.go @@ -2,16 +2,18 @@ package models // Status holds a status type Status struct { - ID int64 `xorm:"int(11) autoincr not null unique pk"` + ID int64 `xorm:"int(11) autoincr not null unique pk"` Name string `xorm:"varchar(250)"` } -func GetStatusList() (status []Status, err error){ +// GetStatusList returns an array with all status +func GetStatusList() (status []Status, err error) { err = x.Find(&status) return status, err } +// GetStatusByID returns a status object with all its infos func GetStatusByID(id int64) (status Status, err error) { _, err = x.Where("id = ?", id).Get(&status) return status, err -} \ No newline at end of file +} diff --git a/routes/api/v1/status.go b/routes/api/v1/status.go index 26e3164..2e12368 100644 --- a/routes/api/v1/status.go +++ b/routes/api/v1/status.go @@ -1,24 +1,24 @@ package v1 import ( - "github.com/labstack/echo" "git.mowie.cc/konrad/Library/models" + "github.com/labstack/echo" "net/http" - "fmt" "strconv" ) +// StatusListShow is the requesthandler to get a list with all status func StatusListShow(c echo.Context) error { status, err := models.GetStatusList() if err != nil { - fmt.Println(err) return c.JSON(http.StatusInternalServerError, models.Message{"An error occured."}) } return c.JSON(http.StatusOK, status) } +// StatusByIDShow is the requesthandler to get a status by its ID func StatusByIDShow(c echo.Context) error { statusIn := c.Param("id") @@ -35,7 +35,6 @@ func StatusByIDShow(c echo.Context) error { status, err := models.GetStatusByID(statusID) if err != nil { - fmt.Println(err) return c.JSON(http.StatusInternalServerError, models.Message{"An error occured."}) }