Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
285a2add53 | ||
|
|
72d0d56868 | ||
|
|
ea4461fd7e | ||
|
|
0f22443b93 |
@@ -1,10 +1,46 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import "github.com/google/uuid"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/tecamino/tecamino-json_data/utils"
|
||||||
|
)
|
||||||
|
|
||||||
type Publish struct {
|
type Publish struct {
|
||||||
Event string `json:"event,omitempty"`
|
Event string `json:"event,omitempty"`
|
||||||
Uuid uuid.UUID `json:"uuid,omitempty"`
|
Uuid uuid.UUID `json:"uuid,omitempty"`
|
||||||
Path string `json:"path,omitempty"`
|
Path string `json:"path,omitempty"`
|
||||||
|
Type Type `json:"type,omitempty"`
|
||||||
Value any `json:"value,omitempty"`
|
Value any `json:"value,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Publish) ConvertValue() any {
|
||||||
|
switch p.Type {
|
||||||
|
case BIT:
|
||||||
|
return utils.BoolFrom(p.Value)
|
||||||
|
case BYS:
|
||||||
|
return utils.Int8From(p.Value)
|
||||||
|
case BYU:
|
||||||
|
return utils.Uint8From(p.Value)
|
||||||
|
case WOS:
|
||||||
|
return utils.Int16From(p.Value)
|
||||||
|
case WOU:
|
||||||
|
return utils.Uint16From(p.Value)
|
||||||
|
case DWS:
|
||||||
|
return utils.Int32From(p.Value)
|
||||||
|
case DWU:
|
||||||
|
return utils.Uint32From(p.Value)
|
||||||
|
case LOS:
|
||||||
|
return utils.Int64From(p.Value)
|
||||||
|
case LOU:
|
||||||
|
return utils.Uint64From(p.Value)
|
||||||
|
case F32:
|
||||||
|
return utils.Float32From(p.Value)
|
||||||
|
case F64:
|
||||||
|
return utils.Float64From(p.Value)
|
||||||
|
case STR:
|
||||||
|
return fmt.Sprintf("%v", p.Value)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "github.com/google/uuid"
|
||||||
|
|
||||||
type Subscribe struct {
|
type Subscribe struct {
|
||||||
Path string `json:"path"`
|
Uuid uuid.UUID `json:"uuid,omitempty"`
|
||||||
|
Path string `json:"path,omitempty"`
|
||||||
Depth uint `json:"depth,omitempty"`
|
Depth uint `json:"depth,omitempty"`
|
||||||
|
Value any `json:"value,omitempty"`
|
||||||
Drivers *Drivers `json:"drivers,omitempty"`
|
Drivers *Drivers `json:"drivers,omitempty"`
|
||||||
Driver string `json:"driver,omitempty"`
|
Driver string `json:"driver,omitempty"`
|
||||||
OnCreate bool `json:"onCreate,omitempty"`
|
OnCreate bool `json:"onCreate,omitempty"`
|
||||||
|
|||||||
Reference in New Issue
Block a user