entity

package
v0.0.0-...-4ac03a4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

type Session struct {
	// contains filtered or unexported fields
}

func NewSession

func NewSession(id, userId uuid.UUID, createdAt time.Time, d time.Duration) *Session

func (Session) CreatedAt

func (s Session) CreatedAt() time.Time

func (Session) ExpiresAt

func (s Session) ExpiresAt() time.Time

func (Session) Id

func (s Session) Id() uuid.UUID

func (Session) UserId

func (s Session) UserId() uuid.UUID

type SessionRepository

type SessionRepository interface {
	Save(ctx context.Context, session *Session) error
}

type Type

type Type string
const (
	DefaultType Type = "default"
	AdminType   Type = "admin"
)

type User

type User struct {
	// contains filtered or unexported fields
}

func NewUser

func NewUser(id uuid.UUID, document, name, email string, birthDate time.Time, userOpts ...UserOption) (*User, error)

NewUser creates a new user

func (*User) ActiveSession

func (u *User) ActiveSession() *Session

func (*User) BirthDate

func (u *User) BirthDate() time.Time

func (*User) Document

func (u *User) Document() string

func (*User) Email

func (u *User) Email() string

func (*User) ID

func (u *User) ID() uuid.UUID

func (*User) Name

func (u *User) Name() string

func (*User) NewSession

func (u *User) NewSession(sessionId uuid.UUID, createdAt time.Time, d time.Duration, secretKey string) (string, error)

func (*User) Password

func (u *User) Password() string

func (*User) Type

func (u *User) Type() Type

type UserOption

type UserOption func(*User) error

func WithPassword

func WithPassword(password string) UserOption

func WithPasswordHashed

func WithPasswordHashed(passwordHashed string) UserOption

func WithType

func WithType(userType Type) UserOption

type UserRepository

type UserRepository interface {
	GetUserByDocument(ctx context.Context, document string) (*User, error)
	GetUserByEmail(ctx context.Context, email string) (*User, error)
	Create(ctx context.Context, user *User) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL