category.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package model // import "miniflux.app/v2/internal/model"
  4. import "fmt"
  5. // Category represents a feed category.
  6. type Category struct {
  7. ID int64 `json:"id"`
  8. Title string `json:"title"`
  9. UserID int64 `json:"user_id"`
  10. HideGlobally bool `json:"hide_globally"`
  11. FeedCount *int `json:"feed_count,omitempty"`
  12. TotalUnread *int `json:"total_unread,omitempty"`
  13. }
  14. func (c *Category) String() string {
  15. return fmt.Sprintf("ID=%d, UserID=%d, Title=%s", c.ID, c.UserID, c.Title)
  16. }
  17. // CategoryRequest represents the request to create or update a category.
  18. type CategoryRequest struct {
  19. Title string `json:"title"`
  20. HideGlobally string `json:"hide_globally"`
  21. }
  22. // Patch updates category fields.
  23. func (cr *CategoryRequest) Patch(category *Category) {
  24. category.Title = cr.Title
  25. category.HideGlobally = cr.HideGlobally != ""
  26. }
  27. // Categories represents a list of categories.
  28. type Categories []*Category