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.
|
|
package models
import "github.com/gisle/stufflog/internal/generate"
type Item struct { ID string `json:"id" msgpack:"id"` UserID string `json:"userId" msgpack:"userId"` Active bool `json:"active" msgpack:"active"` Name string `json:"name" msgpack:"name"` Multiplier float64 `json:"multiplier" msgpack:"multiplier"` }
func (item *Item) GenerateID() { item.ID = generate.ID("I", 16) }
func (item *Item) ApplyUpdate(update ItemUpdate) error { if update.SetActive != nil { item.Active = *update.SetActive } if update.SetName != nil { item.Name = *update.SetName }
return nil }
type ItemUpdate struct { SetName *string `json:"setName"` SetActive *bool `json:"setActive"` }
type ItemsByName []*Item
func (items ItemsByName) Len() int { return len(items) }
func (items ItemsByName) Less(i, j int) bool { return items[i].Name < items[j].Name }
func (items ItemsByName) Swap(i, j int) { items[i], items[j] = items[j], items[i] }
|