backend/pkg/post/domain/repository/category.go

27 lines
979 B
Go

package repository
import (
"context"
"backend/pkg/post/domain/entity"
)
// CategoryRepository defines the interface for category data access operations
type CategoryRepository interface {
BaseCategoryRepository
FindBySlug(ctx context.Context, slug string) (*entity.Category, error)
FindByParentID(ctx context.Context, parentID string) ([]*entity.Category, error)
FindRootCategories(ctx context.Context) ([]*entity.Category, error)
FindActive(ctx context.Context) ([]*entity.Category, error)
IncrementPostCount(ctx context.Context, categoryID string) error
DecrementPostCount(ctx context.Context, categoryID string) error
}
// BaseCategoryRepository defines basic CRUD operations for categories
type BaseCategoryRepository interface {
Insert(ctx context.Context, data *entity.Category) error
FindOne(ctx context.Context, id string) (*entity.Category, error)
Update(ctx context.Context, data *entity.Category) error
Delete(ctx context.Context, id string) error
}