chore: migrate to gitea
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"budget/internal/storage/dao"
|
||||
"budget/internal/storage/dao/postgresql"
|
||||
"database/sql"
|
||||
|
||||
"gitea.frenchtouch.duckdns.org/kratisto/budget-backend/internal/storage/dao"
|
||||
"gitea.frenchtouch.duckdns.org/kratisto/budget-backend/internal/storage/dao/postgresql"
|
||||
|
||||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
@@ -25,7 +26,12 @@ func (db *Database) GetAllUsers() ([]*User, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
defer func(rows *sql.Rows) {
|
||||
err := rows.Close()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}(rows)
|
||||
|
||||
us := make([]*User, 0)
|
||||
for rows.Next() {
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"budget/handler"
|
||||
"budget/internal/storage/dao/postgresql"
|
||||
"budget/internal/storage/model"
|
||||
"budget/internal/utils"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"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/utils"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"google.golang.org/api/oauth2/v2"
|
||||
)
|
||||
@@ -42,7 +43,7 @@ func (hc *Context) ConnectUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
oauth2Service, err := oauth2.New(&http.Client{})
|
||||
oauth2Service, err := oauth2.NewService(c)
|
||||
if oauth2Service == nil {
|
||||
utils.GetLoggerFromCtx(c).WithError(err).Error(err)
|
||||
utils.JSONError(c.Writer, model.ErrInternalServer)
|
||||
@@ -87,7 +88,7 @@ func (hc *Context) CreateUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
oauth2Service, err := oauth2.New(&http.Client{})
|
||||
oauth2Service, err := oauth2.NewService(c)
|
||||
if oauth2Service == nil {
|
||||
utils.GetLogger().WithError(err).Error(err)
|
||||
utils.JSONError(c.Writer, model.ErrInternalServer)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package user
|
||||
|
||||
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 {
|
||||
@@ -16,8 +16,8 @@ func NewService(database *Database) *Service {
|
||||
func (s *Service) GetUserById(userId string) (*User, error) {
|
||||
user, err := s.db.GetUsersByID(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
|
||||
|
||||
Reference in New Issue
Block a user