big refacto

This commit is contained in:
2023-10-03 00:40:01 +02:00
parent aa722718f7
commit 932f423faf
35 changed files with 354 additions and 934 deletions

View File

@@ -2,10 +2,9 @@ package expense
import (
"encoding/csv"
"gopkg.in/go-playground/validator.v9"
"net/http"
"nos-comptes/handler"
"nos-comptes/internal/account"
"nos-comptes/internal/storage/dao/postgresql"
"nos-comptes/internal/storage/model"
"nos-comptes/internal/storage/validators"
"nos-comptes/internal/utils"
@@ -18,7 +17,7 @@ type Context struct {
service *Service
db *Database
accountService *account.Service
*handler.Context
validator *validator.Validate
}
func (c *Context) ImportExpenseFromCSV(gc *gin.Context) {
@@ -124,9 +123,6 @@ func (c *Context) GetAnExpenses(context *gin.Context) {
}
func NewHandler(ctx *handler.Context, db *postgresql.DatabasePostgreSQL) *Context {
database := NewDatabase(db)
service := NewService(database)
accountService := account.NewService(account.NewDatabase(db))
return &Context{service: service, db: database, accountService: accountService, Context: ctx}
func NewHandler(validator *validator.Validate, database *Database, service *Service, accountService *account.Service) *Context {
return &Context{service: service, db: database, accountService: accountService, validator: validator}
}