userapp

package
v0.0.0-...-da924b9 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App manages the set of app layer api functions for the user domain.

func NewApp

func NewApp(userBus *userbus.Business) *App

NewApp constructs a user app API for use.

func NewAppWithAuth

func NewAppWithAuth(userBus *userbus.Business) *App

NewAppWithAuth constructs a user app API for use with auth support.

func (*App) Create

func (a *App) Create(ctx context.Context, app NewUser) (User, error)

Create adds a new user to the system.

func (*App) Delete

func (a *App) Delete(ctx context.Context, userID string) error

Delete removes a user from the system.

func (*App) Query

func (a *App) Query(ctx context.Context, qp QueryParams) (page.Document[User], error)

Query returns a list of users with paging.

func (*App) QueryByID

func (a *App) QueryByID(ctx context.Context, userID string) (User, error)

QueryByID returns a user by its Ia.

func (*App) Update

func (a *App) Update(ctx context.Context, userID string, app UpdateUser) (User, error)

Update updates an existing user.

func (*App) UpdateRole

func (a *App) UpdateRole(ctx context.Context, userID string, app UpdateUserRole) (User, error)

UpdateRole updates an existing user's role.

type NewUser

type NewUser struct {
	Name            string   `json:"name" validate:"required"`
	Email           string   `json:"email" validate:"required,email"`
	Roles           []string `json:"roles" validate:"required"`
	Guild           string   `json:"guild"`
	Password        string   `json:"password" validate:"required"`
	PasswordConfirm string   `json:"passwordConfirm" validate:"eqfield=Password"`
}

NewUser defines the data needed to add a new user.

func (*NewUser) Decode

func (app *NewUser) Decode(data []byte) error

Decode implments the decoder interface.

func (NewUser) Validate

func (app NewUser) Validate() error

Validate checks the data in the model is considered clean.

type QueryParams

type QueryParams struct {
	Page             string
	Rows             string
	OrderBy          string
	ID               string
	Name             string
	Email            string
	StartCreatedDate string
	EndCreatedDate   string
}

QueryParams represents the set of possible query strings.

type UpdateUser

type UpdateUser struct {
	Name            *string `json:"name"`
	Email           *string `json:"email" validate:"omitempty,email"`
	Guild           *string `json:"guild"`
	Password        *string `json:"password"`
	PasswordConfirm *string `json:"passwordConfirm" validate:"omitempty,eqfield=Password"`
	Enabled         *bool   `json:"enabled"`
}

UpdateUser defines the data needed to update a user.

func (*UpdateUser) Decode

func (app *UpdateUser) Decode(data []byte) error

Decode implments the decoder interface.

func (UpdateUser) Validate

func (app UpdateUser) Validate() error

Validate checks the data in the model is considered clean.

type UpdateUserRole

type UpdateUserRole struct {
	Roles []string `json:"roles" validate:"required"`
}

UpdateUserRole defines the data needed to update a user role.

func (*UpdateUserRole) Decode

func (app *UpdateUserRole) Decode(data []byte) error

Decode implments the decoder interface.

func (UpdateUserRole) Validate

func (app UpdateUserRole) Validate() error

Validate checks the data in the model is considered clean.

type User

type User struct {
	ID           string   `json:"id"`
	Name         string   `json:"name"`
	Email        string   `json:"email"`
	Roles        []string `json:"roles"`
	PasswordHash []byte   `json:"-"`
	Guild        string   `json:"guild"`
	Enabled      bool     `json:"enabled"`
	DateCreated  string   `json:"dateCreated"`
	DateUpdated  string   `json:"dateUpdated"`
}

User represents information about an individual user.

func (User) Encode

func (app User) Encode() ([]byte, string, error)

Encode implments the encoder interface.

Jump to

Keyboard shortcuts

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