Added NewCategory() func. And now NewCategory() method needs a Category as an arg.
This commit is contained in:
parent
63dbef6b37
commit
2fb6176b50
@ -12,6 +12,13 @@ type Category struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
func NewCategory(name string) (*Category, error) {
|
||||
if name == "" {
|
||||
return nil, errors.New("category's name should not be empty")
|
||||
}
|
||||
return &Category{Name: name}, nil
|
||||
}
|
||||
|
||||
type Post struct {
|
||||
ID int64
|
||||
Category Category
|
||||
@ -42,7 +49,7 @@ type Mindflow interface {
|
||||
EditPost(post *Post) error
|
||||
DeletePost(id int64) error
|
||||
Posts() ([]Post, error)
|
||||
NewCategory(name string) (int64, error)
|
||||
NewCategory(category *Category) (int64, error)
|
||||
EditCategory(category *Category) error
|
||||
DeleteCategory(id int64) error
|
||||
DeleteUnusedCategories() error
|
||||
|
Loading…
Reference in New Issue
Block a user