refactor: swap strings with an SQL builder #45

Merged
satprog merged 2 commits from feat/sql-builder into main 2025-09-05 21:15:21 +00:00
Showing only changes of commit 547698872d - Show all commits

View File

@ -21,7 +21,7 @@ func (server *ServerImpl) GetBanks(ctx echo.Context) error {
banks, err := server.Dal.Banks()
if err != nil {
return ctx.NoContent(http.StatusInternalServerError)
return err
}
if len(banks) == 0 {
@ -36,8 +36,7 @@ func (server *ServerImpl) GetBankById(ctx echo.Context, bankId string) error {
bank, err := server.Dal.Bank(bankId)
if err != nil {
log.Printf("%v", err)
return ctx.NoContent(http.StatusInternalServerError)
return err
}
if bank == nil {
@ -78,8 +77,7 @@ func (server *ServerImpl) GetTransactionById(ctx echo.Context, transactionId int
transaction, err := server.Dal.Transaction(transactionId)
if err != nil {
log.Printf("%v", err)
return ctx.NoContent(http.StatusInternalServerError)
return err
}
if transaction == nil {
@ -98,8 +96,7 @@ func (server *ServerImpl) CreateTransaction(ctx echo.Context) error {
transaction, err := server.Dal.InsertTransaction(transaction2entity(*t))
if err != nil {
log.Printf("%v", err)
return ctx.NoContent(http.StatusInternalServerError)
return err
}
return ctx.JSON(http.StatusCreated, entity2transaction(transaction))
@ -107,8 +104,7 @@ func (server *ServerImpl) CreateTransaction(ctx echo.Context) error {
func (server *ServerImpl) UpdateTransaction(ctx echo.Context, transactionId int64) error {
if exists, err := server.Dal.TransactionExists(entity.TransactionId(transactionId)); err != nil {
log.Printf("%v", err)
return ctx.NoContent(http.StatusInternalServerError)
return err
} else if !exists {
return ctx.NoContent(http.StatusNotFound)
}
@ -121,8 +117,7 @@ func (server *ServerImpl) UpdateTransaction(ctx echo.Context, transactionId int6
success, err := server.Dal.UpdateTransaction(entity.TransactionId(transactionId), update.Category)
if err != nil {
log.Printf("%v", err)
return ctx.NoContent(http.StatusInternalServerError)
return err
}
if !success {
@ -134,7 +129,7 @@ func (server *ServerImpl) UpdateTransaction(ctx echo.Context, transactionId int6
func (server *ServerImpl) GetCategories(ctx echo.Context) error {
categories, err := server.Dal.Categories()
if err != nil {
return ctx.NoContent(http.StatusInternalServerError)
return err
}
if len(categories) == 0 {