25 lines
590 B
Go
25 lines
590 B
Go
package repositories
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
"github.com/theorift/white-zone-bot/models"
|
|
)
|
|
|
|
type UserRepository interface {
|
|
// Core operations
|
|
GetUser(id int64) (models.User, error)
|
|
CreateUser(id int64, referrerID int64) error
|
|
UpsertReferrer(id int64, referrerID int64) error
|
|
|
|
// Atomic points operations
|
|
AddPointsToUser(id int64, points int64) error
|
|
ReducePointsFromUser(id int64, points int64) (int64, error)
|
|
|
|
// Transaction support
|
|
WithTx(tx *sql.Tx) UserRepository
|
|
BeginTx() (*sql.Tx, error)
|
|
Commit(tx *sql.Tx) error
|
|
Rollback(tx *sql.Tx) error
|
|
}
|