implement new json_data model
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
package models
|
||||
|
||||
type JsonData struct {
|
||||
Set *[]Set `json:"set,omitempty"`
|
||||
Create *[]Bus `json:"create,omitempty"`
|
||||
}
|
||||
|
||||
func NewRequest() *JsonData {
|
||||
return &JsonData{}
|
||||
|
||||
}
|
||||
|
||||
func (r *JsonData) AddSet(bus string, address uint, value uint8) {
|
||||
if r.Set == nil {
|
||||
r.Set = &[]Set{}
|
||||
}
|
||||
|
||||
*r.Set = append(*r.Set, Set{
|
||||
Bus: bus,
|
||||
Address: address,
|
||||
Value: value,
|
||||
})
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
package models
|
||||
|
||||
type JsonResponse struct {
|
||||
Error bool `json:"error,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Data string `json:"data,omitempty"`
|
||||
}
|
25
models/subscriptions.go
Normal file
25
models/subscriptions.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
type Subscriptions map[uuid.UUID]Subscription
|
||||
|
||||
type Subscription struct {
|
||||
Bus string
|
||||
Address uint
|
||||
}
|
||||
|
||||
func NewSubscriptions() Subscriptions {
|
||||
return make(Subscriptions)
|
||||
}
|
||||
|
||||
func (s *Subscriptions) AddSubscription(uid uuid.UUID, drv *json_dataModels.Driver) {
|
||||
sub := Subscription{
|
||||
Bus: drv.Bus,
|
||||
Address: drv.Address,
|
||||
}
|
||||
(*s)[uid] = sub
|
||||
}
|
Reference in New Issue
Block a user