user

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateDTO

type CreateDTO struct {
	FirstName string `validate:"required"`
	LastName  string `validate:"required"`
	Email     string `validate:"required,email"`
	Password  string
	RoleID    uint `validate:"required"`
}

func (*CreateDTO) Ok

func (u *CreateDTO) Ok(l ut.Translator) (map[string]string, bool)

func (*CreateDTO) ToEntity

func (u *CreateDTO) ToEntity() *User

type CreatedEvent

type CreatedEvent struct {
	Sender  User
	Session session.Session
	Data    User
	Result  User
}

func NewCreatedEvent

func NewCreatedEvent(ctx context.Context, data User) (*CreatedEvent, error)

type DeletedEvent

type DeletedEvent struct {
	Sender  User
	Session session.Session
	Result  User
}

func NewDeletedEvent

func NewDeletedEvent(ctx context.Context) (*DeletedEvent, error)

type Repository

type Repository interface {
	Count(ctx context.Context) (int64, error)
	GetAll(ctx context.Context) ([]*User, error)
	GetByEmail(ctx context.Context, email string) (*User, error)
	GetPaginated(ctx context.Context, limit, offset int, sortBy []string) ([]*User, error)
	GetByID(ctx context.Context, id uint) (*User, error)
	Create(ctx context.Context, user *User) error
	CreateOrUpdate(ctx context.Context, user *User) error
	Update(ctx context.Context, user *User) error
	UpdateLastAction(ctx context.Context, id uint) error
	UpdateLastLogin(ctx context.Context, id uint) error
	Delete(ctx context.Context, id uint) error
}

type UILanguage

type UILanguage string
const (
	UILanguageEN UILanguage = "en"
	UILanguageRU UILanguage = "ru"
	UILanguageUZ UILanguage = "uz"
)

func NewUILanguage

func NewUILanguage(l string) (UILanguage, error)

func (UILanguage) IsValid

func (l UILanguage) IsValid() bool

type UpdateDTO

type UpdateDTO struct {
	FirstName string `validate:"required"`
	LastName  string `validate:"required"`
	Email     string `validate:"required,email"`
	Password  string
	RoleID    uint
}

func (*UpdateDTO) Ok

func (u *UpdateDTO) Ok(l ut.Translator) (map[string]string, bool)

func (*UpdateDTO) ToEntity

func (u *UpdateDTO) ToEntity(id uint) *User

type UpdatedEvent

type UpdatedEvent struct {
	Sender  User
	Session session.Session
	Data    User
	Result  User
}

func NewUpdatedEvent

func NewUpdatedEvent(ctx context.Context, data User) (*UpdatedEvent, error)

type User

type User struct {
	ID         uint
	FirstName  string `validate:"required"`
	LastName   string `validate:"required"`
	MiddleName string
	Password   string
	Email      string `validate:"required,email"`
	AvatarID   *uint
	Avatar     *upload.Upload
	EmployeeID *uint
	LastIP     *string
	UILanguage UILanguage
	LastLogin  *time.Time
	LastAction *time.Time
	CreatedAt  time.Time
	UpdatedAt  time.Time
	Roles      []*role.Role
}

func (*User) Can

func (u *User) Can(perm permission.Permission) bool

func (*User) CheckPassword

func (u *User) CheckPassword(password string) bool

func (*User) FullName

func (u *User) FullName() string

func (*User) Ok

func (u *User) Ok(l ut.Translator) (map[string]string, bool)

func (*User) SetPassword

func (u *User) SetPassword(password string) error

func (*User) ToGraph

func (u *User) ToGraph() *model.User

Jump to

Keyboard shortcuts

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