category.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2017 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package model // import "miniflux.app/model"
  5. import "fmt"
  6. // Category represents a feed category.
  7. type Category struct {
  8. ID int64 `json:"id"`
  9. Title string `json:"title"`
  10. UserID int64 `json:"user_id"`
  11. HideGlobally bool `json:"hide_globally"`
  12. FeedCount int `json:"-"`
  13. TotalUnread int `json:"-"`
  14. }
  15. func (c *Category) String() string {
  16. return fmt.Sprintf("ID=%d, UserID=%d, Title=%s", c.ID, c.UserID, c.Title)
  17. }
  18. // CategoryRequest represents the request to create or update a category.
  19. type CategoryRequest struct {
  20. Title string `json:"title"`
  21. HideGlobally string `json:"hide_globally"`
  22. }
  23. // Patch updates category fields.
  24. func (cr *CategoryRequest) Patch(category *Category) {
  25. category.Title = cr.Title
  26. category.HideGlobally = cr.HideGlobally != ""
  27. }
  28. // Categories represents a list of categories.
  29. type Categories []*Category