vikunja-api/models/helper.go

29 lines
447 B
Go
Raw Normal View History

package models
import (
"github.com/labstack/echo"
"strconv"
)
func GetIntURLParam(param string, c echo.Context) (intParam int64, err error) {
id := c.Param(param)
if id != "" {
intParam, err = strconv.ParseInt(id, 10, 64)
}
return intParam, err
}
2018-07-07 14:19:34 +02:00
func GetByID(id int64, result interface{}) (err error) {
exists, err := x.ID(id).Get(result)
if err != nil {
return err
}
if !exists {
return ErrListDoesNotExist{}
}
return
}