mirror of
https://github.com/miniflux/v2.git
synced 2025-08-11 17:51:01 +00:00
First commit
This commit is contained in:
commit
8ffb773f43
2121 changed files with 1118910 additions and 0 deletions
51
model/category.go
Normal file
51
model/category.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
// 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.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Category struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
UserID int64 `json:"user_id,omitempty"`
|
||||
FeedCount int `json:"nb_feeds,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Category) String() string {
|
||||
return fmt.Sprintf("ID=%d, UserID=%d, Title=%s", c.ID, c.UserID, c.Title)
|
||||
}
|
||||
|
||||
func (c Category) ValidateCategoryCreation() error {
|
||||
if c.Title == "" {
|
||||
return errors.New("The title is mandatory")
|
||||
}
|
||||
|
||||
if c.UserID == 0 {
|
||||
return errors.New("The userID is mandatory")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c Category) ValidateCategoryModification() error {
|
||||
if c.Title == "" {
|
||||
return errors.New("The title is mandatory")
|
||||
}
|
||||
|
||||
if c.UserID == 0 {
|
||||
return errors.New("The userID is mandatory")
|
||||
}
|
||||
|
||||
if c.ID == 0 {
|
||||
return errors.New("The ID is mandatory")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type Categories []*Category
|
Loading…
Add table
Add a link
Reference in a new issue