Fixed Lint + gofmt

This commit is contained in:
konrad 2017-11-15 16:16:44 +01:00 committed by kolaente
parent f48de8e75f
commit 0e814d026e
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 8 additions and 7 deletions

View File

@ -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
}
}

View File

@ -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."})
}