1
0

Added NewCategory() func. And now NewCategory() method needs a Category as an arg.

This commit is contained in:
Alexander Andreev 2023-05-23 02:44:54 +04:00
parent 63dbef6b37
commit 2fb6176b50
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -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