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.

26 lines
567 B

3 years ago
  1. package models
  2. import (
  3. "context"
  4. "strings"
  5. )
  6. type ColorPreset struct {
  7. ID int `json:"id"`
  8. Name string `json:"name"`
  9. Value ColorValue `json:"value"`
  10. }
  11. type ColorPresetRepository interface {
  12. Find(ctx context.Context, id int) (ColorPreset, error)
  13. FetchAll(ctx context.Context) ([]ColorPreset, error)
  14. Save(ctx context.Context, preset *ColorPreset) error
  15. Delete(ctx context.Context, preset *ColorPreset) error
  16. }
  17. func (c *ColorPreset) Validate() {
  18. c.Name = strings.Trim(c.Name, " \t\n")
  19. if len(c.Name) == 0 {
  20. c.Name = c.Value.String()
  21. }
  22. }