diff options
author | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-10-07 01:06:55 +0300 |
---|---|---|
committer | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-10-07 01:18:35 +0300 |
commit | 420e049415c8ec7f7a209a03110eecbe0c83e9e0 (patch) | |
tree | e93f7faf8c9704daa24c2653ca50b4f222fa2305 /pkg/handler/admin.go | |
parent | 0617918eb941c401b687d4a0dbc2a54c19e06fd1 (diff) |
Мелкие правки
Diffstat (limited to 'pkg/handler/admin.go')
-rw-r--r-- | pkg/handler/admin.go | 18 |
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(), "es) + 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) +} |