27 lines
495 B
Go
27 lines
495 B
Go
package quote
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
"sh.org.ru/pkg/model"
|
|
"sh.org.ru/pkg/tpl"
|
|
)
|
|
|
|
func (h *Handler) Quote(c echo.Context) error {
|
|
sid := c.Param("id")
|
|
id, err := strconv.Atoi(sid)
|
|
if err != nil {
|
|
return echo.ErrNotFound
|
|
}
|
|
|
|
quote := new(model.Quote)
|
|
err = h.db.NewSelect().
|
|
Model(quote).
|
|
Where("id = ?", id).Scan(c.Request().Context(), quote)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return tpl.QuotePage(quote).Render(c.Request().Context(), c.Response())
|
|
}
|