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

27 lines
979 B
Go
Raw Normal View History

2025-11-19 05:33:06 +00:00
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)
2025-11-19 09:06:44 +00:00
FindByParentID(ctx context.Context, parentID string) ([]*entity.Category, error)
2025-11-19 05:33:06 +00:00
FindRootCategories(ctx context.Context) ([]*entity.Category, error)
FindActive(ctx context.Context) ([]*entity.Category, error)
2025-11-19 09:06:44 +00:00
IncrementPostCount(ctx context.Context, categoryID string) error
DecrementPostCount(ctx context.Context, categoryID string) error
2025-11-19 05:33:06 +00:00
}
// BaseCategoryRepository defines basic CRUD operations for categories
type BaseCategoryRepository interface {
Insert(ctx context.Context, data *entity.Category) error
2025-11-19 09:06:44 +00:00
FindOne(ctx context.Context, id string) (*entity.Category, error)
2025-11-19 05:33:06 +00:00
Update(ctx context.Context, data *entity.Category) error
2025-11-19 09:06:44 +00:00
Delete(ctx context.Context, id string) error
2025-11-19 05:33:06 +00:00
}