aboutsummaryrefslogtreecommitdiff
path: root/pkg/handler/quote.go
diff options
context:
space:
mode:
authorAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-10-06 17:04:37 +0300
committerAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-10-06 17:04:37 +0300
commit6160b4fdc5f37e4ceaa6b3c5acc855f466049d61 (patch)
treeb6e41f9cad22515a61cc50b0a82d98ee55e0c3e3 /pkg/handler/quote.go
parent81b13617c4d0ca68afb181d1105386f0c339864d (diff)
Первая версия
Diffstat (limited to 'pkg/handler/quote.go')
-rw-r--r--pkg/handler/quote.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/pkg/handler/quote.go b/pkg/handler/quote.go
new file mode 100644
index 0000000..af9fd82
--- /dev/null
+++ b/pkg/handler/quote.go
@@ -0,0 +1,27 @@
+package handler
+
+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 err
+ }
+
+ 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())
+}