remodel json data for compatibility
This commit is contained in:
39
models/set.go
Normal file
39
models/set.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package models
|
||||
|
||||
import "github.com/google/uuid"
|
||||
|
||||
type Set struct {
|
||||
Uuid uuid.UUID `json:"uuid,omitempty"`
|
||||
Path string `json:"path"`
|
||||
Driver *Driver `json:"driver,omitempty"`
|
||||
Drivers *Drivers `json:"drivers,omitempty"`
|
||||
Type Type `json:"type,omitempty"`
|
||||
Value any `json:"value,omitempty"`
|
||||
Rights Rights `json:"rights,omitempty"`
|
||||
Updated bool `json:"-"`
|
||||
}
|
||||
|
||||
func (s *Set) ValueByPath(path string, value any) {
|
||||
s.Path = path
|
||||
s.Value = value
|
||||
}
|
||||
|
||||
func (s *Set) ValueByUuid(uid string, value any) {
|
||||
s.Uuid = uuid.MustParse(uid)
|
||||
s.Value = value
|
||||
}
|
||||
|
||||
func (s *Set) New(path string, typ Type, value any, rights Rights) {
|
||||
s.Path = path
|
||||
s.Type = typ
|
||||
s.Value = value
|
||||
s.Rights = rights.GetRights()
|
||||
}
|
||||
|
||||
func (s *Set) NewDriver(typ, bus string, address uint) {
|
||||
s.Driver = &Driver{
|
||||
Type: typ,
|
||||
Bus: bus,
|
||||
Address: address,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user