37 lines
1005 B
Go

package api
//go:generate go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen --config=api.cfg.yaml ../../docs/openapi.yaml
import (
"database/sql"
"log"
"net/http"
"github.com/labstack/echo/v4"
)
type ServerImpl struct {
db *sql.DB
}
func (*ServerImpl) GetBanks(ctx echo.Context) error {
return echo.NewHTTPError(http.StatusNotImplemented)
}
func (*ServerImpl) GetBanksById(ctx echo.Context, bankId int64) error {
return echo.NewHTTPError(http.StatusNotImplemented)
}
func (pf *ServerImpl) GetTransactions(ctx echo.Context, params GetTransactionsParams) error {
rows, err := pf.db.Query("SELECT t.category, t.date, t.description, t.id, tc.amount FROM pfbudget.transactions t LEFT JOIN pfbudget.transactions_categorized tc ON t.id = tc.id")
if err != nil {
log.Fatal(err)
}
return ctx.JSON(http.StatusOK, convert[Transaction](rows))
}
func (*ServerImpl) GetTransactionsById(ctx echo.Context, transactionId int64) error {
return echo.NewHTTPError(http.StatusNotImplemented)
}