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.

47 lines
1.1 KiB

3 years ago
  1. package models
  2. import "context"
  3. type Group struct {
  4. ID string `json:"id" db:"group_id"`
  5. UserID string `json:"-" db:"user_id"`
  6. Name string `json:"name" db:"name"`
  7. Icon string `json:"icon" db:"icon"`
  8. Description string `json:"description" db:"description"`
  9. }
  10. func (g *Group) Update(update GroupUpdate) {
  11. if update.Name != nil {
  12. g.Name = *update.Name
  13. }
  14. if update.Icon != nil {
  15. g.Icon = *update.Icon
  16. }
  17. if update.Description != nil {
  18. g.Description = *update.Description
  19. }
  20. }
  21. type GroupUpdate struct {
  22. Name *string `json:"name"`
  23. Icon *string `jsoN:"icon"`
  24. Description *string `json:"description"`
  25. }
  26. type GroupResult struct {
  27. Group
  28. Items []*Item `json:"items"`
  29. }
  30. type GroupFilter struct {
  31. UserID string
  32. IDs []string
  33. }
  34. type GroupRepository interface {
  35. Find(ctx context.Context, id string) (*Group, error)
  36. List(ctx context.Context, filter GroupFilter) ([]*Group, error)
  37. Insert(ctx context.Context, group Group) error
  38. Update(ctx context.Context, group Group) error
  39. Delete(ctx context.Context, group Group) error
  40. }