aboutsummaryrefslogtreecommitdiff
path: root/pkg/handler/admin.go
diff options
context:
space:
mode:
authorAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-10-07 01:06:55 +0300
committerAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-10-07 01:18:35 +0300
commit420e049415c8ec7f7a209a03110eecbe0c83e9e0 (patch)
treee93f7faf8c9704daa24c2653ca50b4f222fa2305 /pkg/handler/admin.go
parent0617918eb941c401b687d4a0dbc2a54c19e06fd1 (diff)
Мелкие правки
Diffstat (limited to 'pkg/handler/admin.go')
-rw-r--r--pkg/handler/admin.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/pkg/handler/admin.go b/pkg/handler/admin.go
index 8531011..75fb650 100644
--- a/pkg/handler/admin.go
+++ b/pkg/handler/admin.go
@@ -55,3 +55,21 @@ func (h *Handler) AdminAction(c echo.Context) error {
return c.Redirect(http.StatusFound, "/admin/")
}
+
+func (h *Handler) AdminExport(c echo.Context) error {
+ quotes := []model.Quote{}
+ err := h.DB.NewSelect().
+ Model((*model.Quote)(nil)).
+ Order("id ASC").
+ Scan(c.Request().Context(), &quotes)
+ if err != nil {
+ return err
+ }
+
+ quotesString := make([]string, 0, len(quotes))
+ for _, q := range quotes {
+ quotesString = append(quotesString, q.Quote)
+ }
+
+ return c.JSON(http.StatusOK, quotesString)
+}