47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
package database
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.uber.org/fx"
|
|
|
|
"payouts/internal/config"
|
|
"payouts/internal/service/database/orm"
|
|
)
|
|
|
|
var Module = fx.Options(
|
|
fx.Provide(New),
|
|
)
|
|
|
|
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)
|
|
GetPayout(payoutModel *orm.Payout, opts ...Optional) (orm.Payout, error)
|
|
CreatePayout(payoutModel *orm.Payout, opts ...Optional) error
|
|
UpdatePayoutById(id uint, updateModel orm.Payout, opts ...Optional) (int, error)
|
|
UpdatePayoutByPayoutID(payoutId string, updateModel orm.Payout, opts ...Optional) (int, error)
|
|
}
|
|
|
|
// Params represents the module input params
|
|
type Params struct {
|
|
fx.In
|
|
|
|
AppConfig *config.App
|
|
}
|
|
|
|
// NewPersistence instantiates the persistence module
|
|
func New(p Params) (Service, error) {
|
|
return NewDatabaseService(p.AppConfig.Database)
|
|
}
|