38 lines
1.3 KiB
Go
38 lines
1.3 KiB
Go
|
|
package repository
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"backend/pkg/post/domain/entity"
|
||
|
|
|
||
|
|
"github.com/gocql/gocql"
|
||
|
|
)
|
||
|
|
|
||
|
|
// LikeRepository defines the interface for like data access operations
|
||
|
|
type LikeRepository interface {
|
||
|
|
BaseLikeRepository
|
||
|
|
FindByTargetID(ctx context.Context, targetID gocql.UUID, targetType string) ([]*entity.Like, error)
|
||
|
|
FindByUserUID(ctx context.Context, userUID string, params *LikeQueryParams) ([]*entity.Like, int64, error)
|
||
|
|
FindByTargetAndUser(ctx context.Context, targetID gocql.UUID, userUID string, targetType string) (*entity.Like, error)
|
||
|
|
CountByTargetID(ctx context.Context, targetID gocql.UUID, targetType string) (int64, error)
|
||
|
|
DeleteByTargetAndUser(ctx context.Context, targetID gocql.UUID, userUID string, targetType string) error
|
||
|
|
}
|
||
|
|
|
||
|
|
// BaseLikeRepository defines basic CRUD operations for likes
|
||
|
|
type BaseLikeRepository interface {
|
||
|
|
Insert(ctx context.Context, data *entity.Like) error
|
||
|
|
FindOne(ctx context.Context, id gocql.UUID) (*entity.Like, error)
|
||
|
|
Delete(ctx context.Context, id gocql.UUID) error
|
||
|
|
}
|
||
|
|
|
||
|
|
// LikeQueryParams defines query parameters for like listing
|
||
|
|
type LikeQueryParams struct {
|
||
|
|
TargetID *gocql.UUID
|
||
|
|
TargetType *string
|
||
|
|
UserUID *string
|
||
|
|
PageSize int64
|
||
|
|
PageIndex int64
|
||
|
|
OrderBy string // "created_at"
|
||
|
|
OrderDirection string // "ASC", "DESC"
|
||
|
|
}
|