package controller import ( "net/http" "github.com/labstack/echo/v4" "gitrepo.ru/neonxp/nquest/api" "gitrepo.ru/neonxp/nquest/pkg/contextlib" "gitrepo.ru/neonxp/nquest/pkg/service" ) type Admin struct { GameService *service.Game } func (a *Admin) GetAdminGames(ctx echo.Context) error { user := contextlib.GetUser(ctx) games, err := a.GameService.ListByAuthor(ctx.Request().Context(), user) if err != nil { return err } result := make(api.GameAdminList, 0, len(games)) for _, g := range games { result = append(result, api.GameAdminListItem{ Id: int(g.ID), Title: g.Title, CreatedAt: g.CreatedAt.Format("02.01.06 15:04"), }) } return ctx.JSON(http.StatusOK, result) }