Documentation ¶
Index ¶
- Constants
- Variables
- func CommandCreateRules(form *forms.Form)
- func CommandUpdateRules(form *forms.Form)
- func UserCreateRules(form *forms.Form)
- func UserUpdateRules(form *forms.Form)
- type Call
- type CallRepository
- type CallStatus
- type Command
- type CommandImage
- type CommandRepository
- type RedisCallRepository
- func (rcr *RedisCallRepository) Create(call *Call) error
- func (rcr *RedisCallRepository) Delete(call *Call) error
- func (rcr *RedisCallRepository) Find(id int64) (*Call, error)
- func (rcr *RedisCallRepository) FindAllByCommand(command *Command) ([]*Call, error)
- func (rcr *RedisCallRepository) Update(call, newCall *Call) error
- type RedisCommandRepository
- func (rcr *RedisCommandRepository) Create(command *Command, token string) error
- func (rcr *RedisCommandRepository) Delete(command *Command) error
- func (rcr *RedisCommandRepository) Find(id int) (*Command, error)
- func (rcr *RedisCommandRepository) FindAll() ([]*Command, error)
- func (rcr *RedisCommandRepository) Update(command, newCommand *Command) error
- func (rcr *RedisCommandRepository) UpdateToken(command *Command, token string) error
- type RedisUserRepository
- func (rur *RedisUserRepository) Authenticate(usernameOrEmail, password string) (*User, error)
- func (rur *RedisUserRepository) AuthenticateByRememberToken(id int, token string) (*User, error)
- func (rur *RedisUserRepository) Create(user *User) error
- func (rur *RedisUserRepository) Delete(user *User) error
- func (rur *RedisUserRepository) Find(id int) (*User, error)
- func (rur *RedisUserRepository) FindAll() ([]*User, error)
- func (rur *RedisUserRepository) Update(user, newUser *User) error
- func (rur *RedisUserRepository) UpdateRememberToken(user *User, token string) error
- type Timestamp
- type User
- type UserRepository
Constants ¶
View Source
const ( // Door image. Door CommandImage = "door" // Light image. Light CommandImage = "light" // Outlet image. Outlet CommandImage = "outlet" // Plug image. Plug CommandImage = "plug" // Sensor image. Sensor CommandImage = "sensor" // PayloadVariable pattern. PayloadVariable string = "%p" )
Variables ¶
View Source
var ( // ErrDuplicateEmail error. ErrDuplicateEmail = errors.New("models: duplicate email") // ErrDuplicateName error. ErrDuplicateName = errors.New("models: duplicate name") // ErrDuplicateUsername error. ErrDuplicateUsername = errors.New("models: duplicate username") // ErrInvalidCredentials error. ErrInvalidCredentials = errors.New("models: invalid credentials") // ErrInvalidValue error. ErrInvalidValue = errors.New("models: invalid value") // ErrNoRecord error. ErrNoRecord = errors.New("models: no matching record found") // ErrTimestamp error. ErrTimestamp = errors.New("models: invalid timestamp type") )
Functions ¶
Types ¶
type Call ¶
type Call struct { ID int64 `json:"id" redis:"id"` CommandID int `json:"command_id" redis:"command_id"` Status CallStatus `json:"status" redis:"status"` Payload string `json:"payload" redis:"payload"` Output string `json:"output" redis:"output"` CreatedAt Timestamp `json:"created_at" redis:"created_at"` }
Call type.
type CallRepository ¶
type CallRepository interface { Create(*Call) error Find(int64) (*Call, error) FindAllByCommand(*Command) ([]*Call, error) Update(*Call, *Call) error Delete(*Call) error }
CallRepository type.
type CallStatus ¶
type CallStatus string
CallStatus type.
const ( // Pending status. Pending CallStatus = "pending" // InProgress status. InProgress CallStatus = "in_progress" // Completed status. Completed CallStatus = "completed" // Failed status. Failed CallStatus = "failed" )
type Command ¶
type Command struct { ID int `json:"id" redis:"id"` Name string `json:"name" redis:"name"` Token string `json:"-" redis:"token"` Image CommandImage `json:"image" redis:"image"` Value string `json:"value" redis:"value"` CreatedAt Timestamp `json:"created_at" redis:"created_at"` }
Command type.
type CommandRepository ¶
type CommandRepository interface { Create(*Command, string) error Find(int) (*Command, error) FindAll() ([]*Command, error) Update(*Command, *Command) error UpdateToken(*Command, string) error Delete(*Command) error }
CommandRepository type.
type RedisCallRepository ¶
RedisCallRepository type.
func (*RedisCallRepository) Create ¶
func (rcr *RedisCallRepository) Create(call *Call) error
Create function.
func (*RedisCallRepository) Delete ¶
func (rcr *RedisCallRepository) Delete(call *Call) error
Delete function.
func (*RedisCallRepository) Find ¶
func (rcr *RedisCallRepository) Find(id int64) (*Call, error)
Find function.
func (*RedisCallRepository) FindAllByCommand ¶
func (rcr *RedisCallRepository) FindAllByCommand(command *Command) ([]*Call, error)
FindAllByCommand function.
func (*RedisCallRepository) Update ¶
func (rcr *RedisCallRepository) Update(call, newCall *Call) error
Update function.
type RedisCommandRepository ¶
RedisCommandRepository type.
func (*RedisCommandRepository) Create ¶
func (rcr *RedisCommandRepository) Create(command *Command, token string) error
Create function.
func (*RedisCommandRepository) Delete ¶
func (rcr *RedisCommandRepository) Delete(command *Command) error
Delete function.
func (*RedisCommandRepository) Find ¶
func (rcr *RedisCommandRepository) Find(id int) (*Command, error)
Find function.
func (*RedisCommandRepository) FindAll ¶
func (rcr *RedisCommandRepository) FindAll() ([]*Command, error)
FindAll function.
func (*RedisCommandRepository) Update ¶
func (rcr *RedisCommandRepository) Update(command, newCommand *Command) error
Update function.
func (*RedisCommandRepository) UpdateToken ¶
func (rcr *RedisCommandRepository) UpdateToken(command *Command, token string) error
UpdateToken function.
type RedisUserRepository ¶
RedisUserRepository type.
func (*RedisUserRepository) Authenticate ¶
func (rur *RedisUserRepository) Authenticate(usernameOrEmail, password string) (*User, error)
Authenticate function.
func (*RedisUserRepository) AuthenticateByRememberToken ¶
func (rur *RedisUserRepository) AuthenticateByRememberToken(id int, token string) (*User, error)
AuthenticateByRememberToken function.
func (*RedisUserRepository) Create ¶
func (rur *RedisUserRepository) Create(user *User) error
Create function.
func (*RedisUserRepository) Delete ¶
func (rur *RedisUserRepository) Delete(user *User) error
Delete function.
func (*RedisUserRepository) Find ¶
func (rur *RedisUserRepository) Find(id int) (*User, error)
Find function.
func (*RedisUserRepository) FindAll ¶
func (rur *RedisUserRepository) FindAll() ([]*User, error)
FindAll function.
func (*RedisUserRepository) Update ¶
func (rur *RedisUserRepository) Update(user, newUser *User) error
Update function.
func (*RedisUserRepository) UpdateRememberToken ¶
func (rur *RedisUserRepository) UpdateRememberToken(user *User, token string) error
UpdateRememberToken function.
type User ¶
type User struct { ID int `json:"id" redis:"id"` Username string `json:"username" redis:"username"` Email string `json:"email" redis:"email"` Password []byte `json:"-" redis:"password"` RememberToken string `json:"-" redis:"remember_token"` IsEnabled bool `json:"is_enabled" redis:"is_enabled"` CreatedAt Timestamp `json:"created_at" redis:"created_at"` }
User type.
type UserRepository ¶
type UserRepository interface { Create(*User) error Find(int) (*User, error) FindAll() ([]*User, error) Update(*User, *User) error UpdateRememberToken(*User, string) error Authenticate(string, string) (*User, error) AuthenticateByRememberToken(int, string) (*User, error) Delete(*User) error }
UserRepository type.
Click to show internal directories.
Click to hide internal directories.