30 lines
1.0 KiB
Go
30 lines
1.0 KiB
Go
|
|
package repository
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"backend/pkg/post/domain/entity"
|
||
|
|
|
||
|
|
"github.com/gocql/gocql"
|
||
|
|
)
|
||
|
|
|
||
|
|
// 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 *gocql.UUID) ([]*entity.Category, error)
|
||
|
|
FindRootCategories(ctx context.Context) ([]*entity.Category, error)
|
||
|
|
FindActive(ctx context.Context) ([]*entity.Category, error)
|
||
|
|
IncrementPostCount(ctx context.Context, categoryID gocql.UUID) error
|
||
|
|
DecrementPostCount(ctx context.Context, categoryID gocql.UUID) error
|
||
|
|
}
|
||
|
|
|
||
|
|
// BaseCategoryRepository defines basic CRUD operations for categories
|
||
|
|
type BaseCategoryRepository interface {
|
||
|
|
Insert(ctx context.Context, data *entity.Category) error
|
||
|
|
FindOne(ctx context.Context, id gocql.UUID) (*entity.Category, error)
|
||
|
|
Update(ctx context.Context, data *entity.Category) error
|
||
|
|
Delete(ctx context.Context, id gocql.UUID) error
|
||
|
|
}
|
||
|
|
|