2017-11-20 06:10:04 +01:00
|
|
|
// Copyright 2017 Frédéric Guillot. All rights reserved.
|
|
|
|
// Use of this source code is governed by the Apache 2.0
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2018-08-25 06:51:50 +02:00
|
|
|
package model // import "miniflux.app/model"
|
2017-11-20 06:10:04 +01:00
|
|
|
|
2021-01-04 07:28:04 +01:00
|
|
|
import "fmt"
|
2017-11-20 06:10:04 +01:00
|
|
|
|
2021-01-04 07:28:04 +01:00
|
|
|
// Category represents a feed category.
|
2017-11-20 06:10:04 +01:00
|
|
|
type Category struct {
|
2021-01-04 07:28:04 +01:00
|
|
|
ID int64 `json:"id"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
UserID int64 `json:"user_id"`
|
|
|
|
FeedCount int `json:"-"`
|
2017-11-20 06:10:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Category) String() string {
|
|
|
|
return fmt.Sprintf("ID=%d, UserID=%d, Title=%s", c.ID, c.UserID, c.Title)
|
|
|
|
}
|
|
|
|
|
2021-01-04 07:28:04 +01:00
|
|
|
// CategoryRequest represents the request to create or update a category.
|
|
|
|
type CategoryRequest struct {
|
|
|
|
Title string `json:"title"`
|
2017-11-20 06:10:04 +01:00
|
|
|
}
|
|
|
|
|
2021-01-04 07:28:04 +01:00
|
|
|
// Patch updates category fields.
|
|
|
|
func (cr *CategoryRequest) Patch(category *Category) {
|
|
|
|
category.Title = cr.Title
|
2017-11-20 06:10:04 +01:00
|
|
|
}
|
|
|
|
|
2017-11-26 04:06:02 +01:00
|
|
|
// Categories represents a list of categories.
|
2017-11-20 06:10:04 +01:00
|
|
|
type Categories []*Category
|