You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
43 lines
1.4 KiB
package models
|
|
|
|
import "context"
|
|
|
|
// A Button is general information about a button that exists.
|
|
type Button struct {
|
|
ID int `db:"id" json:"id"`
|
|
BridgeID int `db:"bridge_id" json:"bridgeId"`
|
|
InternalIndex int `db:"internal_index" json:"internalIndex"`
|
|
InternalID string `db:"internal_id" json:"internalId"`
|
|
TargetGroupID int `db:"target_group_id" json:"targetGroupId"`
|
|
Name string `db:"name" json:"name"`
|
|
Kind string `db:"kind" json:"kind"`
|
|
Missing bool `db:"missing" json:"missing"`
|
|
NumButtons int `db:"num_buttons" json:"numButtons"`
|
|
}
|
|
|
|
// ButtonEvent is an event.
|
|
type ButtonEvent struct {
|
|
Index int
|
|
Kind string
|
|
}
|
|
|
|
const (
|
|
// ButtonEventKindPress is a button event.
|
|
ButtonEventKindPress = "press"
|
|
// ButtonEventKindRepeat is a button event.
|
|
ButtonEventKindRepeat = "repeat"
|
|
// ButtonEventKindRelease is a button event.
|
|
ButtonEventKindRelease = "release"
|
|
)
|
|
|
|
// ButtonRepository is an interface for all database operations
|
|
// related to the button model.
|
|
type ButtonRepository interface {
|
|
FindByID(ctx context.Context, id int) (Button, error)
|
|
FindByInternalID(ctx context.Context, internalID string) (Button, error)
|
|
List(ctx context.Context) ([]Button, error)
|
|
ListByBridge(ctx context.Context, bridge Bridge) ([]Button, error)
|
|
Insert(ctx context.Context, button Button) (Button, error)
|
|
Update(ctx context.Context, button Button) error
|
|
Remove(ctx context.Context, button Button) error
|
|
}
|