Igris/internal/domain/session.go

42 lines
917 B
Go

package domain
import (
"context"
"time"
"github.com/google/uuid"
)
type SessionRepo interface {
Create(ctx context.Context, session *UserSession) error
GetByID(ctx context.Context, id uuid.UUID) (*UserSession, error)
Delete(ctx context.Context, id uuid.UUID) error
GetUserSessions(ctx context.Context, userID uuid.UUID) ([]UserSession, error)
}
type UserSession struct {
ID uuid.UUID
UserID uuid.UUID
User User
WalletID uuid.UUID
IPaddress string
Agent string
ExpiresAt time.Time
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
}
func NewSession(userID, walletID uuid.UUID, ipAddress, agent string, expiresAt time.Time) *UserSession {
return &UserSession{
ID: uuid.New(),
UserID: userID,
WalletID: walletID,
IPaddress: ipAddress,
Agent: agent,
ExpiresAt: expiresAt,
CreatedAt: time.Now().UTC(),
UpdatedAt: time.Now().UTC(),
}
}