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.

27 lines
622 B

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