chore: migrate to gitea
Some checks failed
golangci-lint / lint (push) Successful in 1m33s
Test / test (push) Failing after 2m16s

This commit is contained in:
2026-01-27 00:12:32 +01:00
parent 79d9f55fdc
commit f81c902ca6
3170 changed files with 1216494 additions and 1586 deletions

View File

@@ -1,11 +1,14 @@
package account
import (
"budget/internal/storage/dao"
"budget/internal/storage/dao/postgresql"
"budget/internal/utils"
"database/sql"
"errors"
"fmt"
"gitea.frenchtouch.duckdns.org/kratisto/budget-backend/internal/storage/dao"
"gitea.frenchtouch.duckdns.org/kratisto/budget-backend/internal/storage/dao/postgresql"
"gitea.frenchtouch.duckdns.org/kratisto/budget-backend/internal/utils"
"github.com/lib/pq"
)
@@ -23,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() {
@@ -45,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

@@ -1,14 +1,15 @@
package account
import (
"budget/handler"
"budget/internal/storage/dao/postgresql"
"budget/internal/storage/model"
"budget/internal/storage/validators"
"budget/internal/user"
"budget/internal/utils"
"net/http"
"gitea.frenchtouch.duckdns.org/kratisto/budget-backend/handler"
"gitea.frenchtouch.duckdns.org/kratisto/budget-backend/internal/storage/dao/postgresql"
"gitea.frenchtouch.duckdns.org/kratisto/budget-backend/internal/storage/model"
"gitea.frenchtouch.duckdns.org/kratisto/budget-backend/internal/storage/validators"
"gitea.frenchtouch.duckdns.org/kratisto/budget-backend/internal/user"
"gitea.frenchtouch.duckdns.org/kratisto/budget-backend/internal/utils"
"github.com/gin-gonic/gin"
)
@@ -75,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

@@ -1,8 +1,8 @@
package account
import (
"budget/internal/storage/dao"
"budget/internal/storage/model"
"gitea.frenchtouch.duckdns.org/kratisto/budget-backend/internal/storage/dao"
"gitea.frenchtouch.duckdns.org/kratisto/budget-backend/internal/storage/model"
)
type Service struct {
@@ -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