models

package
v0.0.0-...-fd9de40 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminLog

type AdminLog struct {
	ID      int    `json:"id"`
	Type    string `json:"type" validate:"required"`
	Details string `json:"details" validate:"required"`
	UserID  int    `json:"userID" validate:"required" db:"user_id"`
	Time    string `json:"time" validate:"required"`
}

AdminLog struct

func (*AdminLog) Add

func (l *AdminLog) Add(env *Env) (int64, error)

Add admin log entry

func (*AdminLog) Find

func (l *AdminLog) Find(env *Env, operator string, fields []WhereFields, perPage int, pageNumber int) (*[]AdminLog, int, error)

Find admin log entries by fields provided

func (*AdminLog) Get

func (l *AdminLog) Get(env *Env) (*AdminLog, error)

Get admin log entries by ID provided

func (*AdminLog) Migrate

func (l *AdminLog) Migrate(env *Env) (sql.Result, error)

Migrate admin log

type Camera

type Camera struct {
	ID        int    `json:"id"`
	Name      string `json:"name"`
	IPAddress string `json:"ipAddress" validate:"required" db:"ip_address"`
	Username  string `json:"username" validate:"required"`
	Password  string `json:"password" validate:"required"`
	CreatedAt string `json:"createdAt" db:"created_at"`
	UpdatedAt string `json:"updatedAt" db:"updated_at"`
}

Camera struct

func (*Camera) Add

func (e *Camera) Add(env *Env) (int64, error)

Add number plate

func (*Camera) Delete

func (e *Camera) Delete(env *Env) (int64, error)

Delete number plate

func (*Camera) Find

func (e *Camera) Find(env *Env, operator string, fields []WhereFields, perPage int, pageNumber int) (*[]Camera, int, error)

Find number plates by fields provided

func (*Camera) Get

func (e *Camera) Get(env *Env) (*Camera, error)

Get number plate by ID provided

func (*Camera) Migrate

func (e *Camera) Migrate(env *Env) (sql.Result, error)

Migrate number plates

func (*Camera) Update

func (e *Camera) Update(env *Env) (int64, error)

Update number plate

type Config

type Config struct {
	HTTPHost          string
	HTTPPort          string
	ExternalURL       string
	SessionKey        string // SessionKey must be 16, 24 or 32 bytes long (AES-128, AES-192 or AES-256)
	SessionCookieName string
	PerPage           string
	SMTPHost          string
	SMTPPort          string
	SMTPUser          string
	SMTPPass          string
	SMTPAuth          string
	SMTPFrom          string
	DBFile            string
}

Config struct

type DB

type DB struct {
	Conn *sqlx.DB

	ErrRecordNotFound error
	// contains filtered or unexported fields
}

func (*DB) Exec

func (d *DB) Exec(query string, args ...interface{}) (sql.Result, error)

func (*DB) Init

func (d *DB) Init(config Config, cache cachego.Cache, logger *log.Logger) error

Init sets up the connection pool global variable.

func (*DB) LimitSQL

func (d *DB) LimitSQL(perPage int, pageNumber int) string

func (*DB) Migrate

func (d *DB) Migrate(env *Env) error

Migrate performs database migrations.

func (*DB) OrderSQL

func (d *DB) OrderSQL(fields []OrderFields, values []interface{}) (string, []interface{})

func (*DB) Query

func (d *DB) Query(resStruct interface{}, query string, args ...interface{}) error

func (*DB) WhereSQL

func (d *DB) WhereSQL(operator string, fields []WhereFields) (string, []interface{})

type Email

type Email struct {
	To      string
	Subject string
	Body    hermes.Body
}

Email struct

func (*Email) Send

func (e *Email) Send(env *Env) error

Send Email

type Env

type Env struct {
	Config              Config
	Logger              *log.Logger
	DB                  *DB
	Cache               *cachego.Cache
	SessionStore        *sessions.CookieStore
	Validator           *validator.Validate
	ValidatorTranslator ut.Translator
	Templates           *template.Template
	EmbedFS             *embed.FS
}

Env struct

type Form

type Form struct {
	Fields     []FormField
	CancelLink string
	SubmitName string
}

Form struct

type FormField

type FormField struct {
	Name        string
	Title       string
	Type        string
	Class       string
	Placeholder string
	Value       string
	Values      []string
	Checked     bool
	Required    bool
}

FormField struct

type List

type List struct {
	Pagination ListPagination
	Rows       []ListRow
}

List struct

type ListPagination

type ListPagination struct {
	Current  int
	Previous int
	Next     int
	Pages    []int
}

ListPagination struct

type ListRow

type ListRow struct {
	Fields []ListRowField
}

ListRow struct

type ListRowField

type ListRowField struct {
	Type       string
	Value      string
	Class      string
	Link       string
	Confirm    string
	Icon       string
	Modal      string
	ModalTitle string
	FieldClass string
}

ListRowField struct

type NumberPlate

type NumberPlate struct {
	ID        int    `json:"id"`
	Plate     string `json:"plate" validate:"required"`
	Name      string `json:"name"`
	CreatedAt string `json:"createdAt" db:"created_at"`
	UpdatedAt string `json:"updatedAt" db:"updated_at"`
}

NumberPlate struct

func (*NumberPlate) Add

func (e *NumberPlate) Add(env *Env) (int64, error)

Add number plate

func (*NumberPlate) Delete

func (e *NumberPlate) Delete(env *Env) (int64, error)

Delete number plate

func (*NumberPlate) Find

func (e *NumberPlate) Find(env *Env, operator string, fields []WhereFields, perPage int, pageNumber int) (*[]NumberPlate, int, error)

Find number plates by fields provided

func (*NumberPlate) Get

func (e *NumberPlate) Get(env *Env) (*NumberPlate, error)

Get number plate by ID provided

func (*NumberPlate) Migrate

func (e *NumberPlate) Migrate(env *Env) (sql.Result, error)

Migrate number plates

func (*NumberPlate) Update

func (e *NumberPlate) Update(env *Env) (int64, error)

Update number plate

type OrderFields

type OrderFields struct {
	Field     string
	Value     any
	Extra     string
	SubFields []OrderFields
}

type Page

type Page struct {
	Type          string
	FormType      string
	Title         string
	View          interface{}
	ErrorMessages []string
	OkMessage     string
	RequestURL    string
	Theme         string
}

type User

type User struct {
	ID           int    `json:"id"`
	Email        string `json:"email" validate:"omitempty,email"`
	Password     string `json:"-" validate:"omitempty,passwd"`
	PasswordHash string `json:"-" db:"password_hash"`
	CreatedAt    string `json:"createdAt" db:"created_at"`
	UpdatedAt    string `json:"updatedAt" db:"updated_at"`
}

User struct

func (*User) Add

func (s *User) Add(env *Env) (int64, error)

Add user

func (*User) CheckLogin

func (s *User) CheckLogin(env *Env) (*User, bool, error)

CheckLogin checks if an email and password combination are valid

func (*User) Delete

func (s *User) Delete(env *Env) (int64, error)

Delete user

func (*User) Find

func (s *User) Find(env *Env, operator string, fields []WhereFields, perPage int, pageNumber int) (*[]User, int, error)

Find user by fields provided

func (*User) Get

func (s *User) Get(env *Env) (*User, error)

Get user by ID provided

func (*User) Migrate

func (s *User) Migrate(env *Env) (sql.Result, error)

Migrate user

func (*User) Update

func (s *User) Update(env *Env) (int64, error)

Update user

type WhereFields

type WhereFields struct {
	Field              string
	ComparisonOperator string
	Value              any
}

Jump to

Keyboard shortcuts

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