chore: migrate to gitea
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user