Handlers, DB, Cache

This commit is contained in:
2026-03-10 19:17:43 +03:00
parent e56b1f1305
commit 968c030939
23 changed files with 566 additions and 34 deletions

View File

@@ -1,16 +1,32 @@
package database
import (
"payouts/internal/config"
"context"
"go.uber.org/fx"
"payouts/internal/config"
"payouts/internal/service/database/orm"
)
var Module = fx.Options(
fx.Provide(New),
)
type DatabaseService interface {
type params struct {
ctx context.Context
}
type Optional func(*params)
func WithContext(ctx context.Context) Optional {
return func(p *params) {
p.ctx = ctx
}
}
type Service interface {
CreateUser(user orm.User, opts ...Optional) error
GetUser(user orm.User, opts ...Optional) (orm.User, error)
}
// Params represents the module input params
@@ -21,6 +37,6 @@ type Params struct {
}
// NewPersistence instantiates the persistence module
func New(p Params) (DatabaseService, error) {
return NewDatabaseService(p.AppConfig.Database.Type, p.AppConfig.Database.Connection, p.AppConfig.Database.LogLevel)
func New(p Params) (Service, error) {
return NewDatabaseService(p.AppConfig.Database)
}