chore: migrate to gitea
Some checks failed
golangci-lint / lint (push) Failing after 21s
Test / test (push) Failing after 2m17s

This commit is contained in:
2026-01-27 01:40:31 +01:00
parent a9bca767a9
commit 1a27ed5274
3163 changed files with 1216358 additions and 1529 deletions

View File

@@ -1,6 +1,8 @@
package account
import (
"database/sql"
"errors"
"fmt"
"gitea.frenchtouch.duckdns.org/kratisto/budget-backend/internal/storage/dao"
@@ -24,7 +26,12 @@ func (db *Database) GetAllAccountOfUser(id string) ([]*Account, error) {
if err != nil {
return nil, err
}
defer rows.Close()
defer func(rows *sql.Rows) {
err := rows.Close()
if err != nil {
return
}
}(rows)
as := make([]*Account, 0)
for rows.Next() {
@@ -46,15 +53,22 @@ func (db *Database) GetAccountWithNameForUser(name string, id string) (*Account,
AND a.name = $2
`
row, err := db.Session.Query(q, id, name)
if err != nil {
return nil, err
}
if !row.Next() {
return nil, dao.NewDAOError(dao.ErrTypeNotFound, fmt.Errorf("No row found"))
return nil, dao.NewDAOError(dao.ErrTypeNotFound, fmt.Errorf("no row found"))
}
a := Account{}
row.Scan(&a.ID, &a.UserId, &a.Name, &a.Provider, &a.CreatedAt, &a.UpdatedAt)
err = row.Scan(&a.ID, &a.UserId, &a.Name, &a.Provider, &a.CreatedAt, &a.UpdatedAt)
if err != nil {
return nil, err
}
if row.Next() {
return nil, fmt.Errorf("Impossibru")
}
if errPq, ok := err.(*pq.Error); ok {
var errPq *pq.Error
if errors.As(err, &errPq) {
return nil, postgresql.HandlePgError(errPq)
}
if err != nil {

View File

@@ -76,13 +76,15 @@ func (c *Context) CreateAccountOfUser(gc *gin.Context) {
return
}
utils.JSON(gc.Writer, http.StatusCreated, accountSaved)
return
}
func (c *Context) DeleteAccountOfUser(gc *gin.Context) {
userId := gc.Param("userId")
accountId := gc.Param("accountId")
c.service.DeleteAccountOfUser(userId, accountId)
err := c.service.DeleteAccountOfUser(userId, accountId)
if err != nil {
return
}
}

View File

@@ -12,8 +12,8 @@ type Service struct {
func (s *Service) GetAllAccountOfUser(userId string) ([]*Account, error) {
accounts, err := s.db.GetAllAccountOfUser(userId)
if e, ok := err.(*dao.Error); ok {
switch {
case e.Type == dao.ErrTypeNotFound:
switch e.Type {
case dao.ErrTypeNotFound:
return nil, &model.ErrNotFound
default:
return nil, &model.ErrInternalServer
@@ -31,8 +31,8 @@ func (s *Service) GetAllAccountOfUser(userId string) ([]*Account, error) {
func (s *Service) GetAccountWithNameForUser(name string, id string) (*Account, error) {
account, err := s.db.GetAccountWithNameForUser(name, id)
if e, ok := err.(*dao.Error); ok {
switch {
case e.Type == dao.ErrTypeNotFound:
switch e.Type {
case dao.ErrTypeNotFound:
return nil, &model.ErrNotFound
default:
return nil, &model.ErrInternalServer