controller

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPageSize = 20

Variables

View Source
var ErrorUnauthorized = fmt.Errorf("unauthorized")

Functions

This section is empty.

Types

type APIKeyFilter

type APIKeyFilter struct {
	Page        int64   `json:"page"`
	PageSize    int64   `json:"pageSize"`
	VehicleUUID *string `json:"vehicleUUID"`
}

type Controller

type Controller struct {
	Session *session.JWT
	DB      *gorm.DB
	Map     *maps.Map
}

func New

func New(secret []byte, db *gorm.DB, m *maps.Map) *Controller

func NewTest

func NewTest() *Controller

func (*Controller) AuthorizeUser

func (c *Controller) AuthorizeUser(tokenString string) (*models.User, error)

func (*Controller) Close

func (c *Controller) Close()

func (*Controller) CreateAPIKey

func (c *Controller) CreateAPIKey(apiKey *models.APIKey) error

func (*Controller) CreateUser

func (c *Controller) CreateUser(user *models.User) error

func (*Controller) CreateVehicle

func (c *Controller) CreateVehicle(vehicle *models.Vehicle) error

func (*Controller) DeleteAPIKey

func (c *Controller) DeleteAPIKey(apiKeyUUID string) error

func (*Controller) DeleteUser

func (c *Controller) DeleteUser(userUUID string) error

func (*Controller) DeleteVehicle

func (c *Controller) DeleteVehicle(vehicleUUID string) error

func (*Controller) Login

func (c *Controller) Login(credentials *models.User) (string, error)

func (*Controller) QueryAPIKeys

func (c *Controller) QueryAPIKeys(filter *APIKeyFilter) (*Result[*models.APIKey], error)

func (*Controller) QueryUsers

func (c *Controller) QueryUsers(filter *UserFilter) (*Result[*models.User], error)

func (*Controller) QueryVehicles

func (c *Controller) QueryVehicles(filter *VehicleFilter) (*Result[*models.Vehicle], error)

func (*Controller) UpdateUser

func (c *Controller) UpdateUser(user *models.User) error

func (*Controller) UpdateVehicle

func (c *Controller) UpdateVehicle(vehicle *models.Vehicle) error

func (*Controller) UserValid

func (c *Controller) UserValid(user *models.User) (*models.User, error)

type Result

type Result[T any] struct {
	Page       int64 `json:"page"`
	TotalPages int64 `json:"totalPages"`
	Results    []T
}

type UserFilter

type UserFilter struct {
	Page     int64            `json:"page"`
	PageSize int64            `json:"pageSize"`
	Username *string          `json:"username,omitempty"`
	Type     *models.UserType `json:"userType,omitempty"`
}

type VehicleFilter

type VehicleFilter struct {
	Page     int64   `json:"page"`
	PageSize int64   `json:"pageSize"`
	Name     *string `json:"name,omitempty"`
	Plate    *string `json:"plate,omitempty"`
}

Jump to

Keyboard shortcuts

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