package com.caliverse.admin.dynamodb.repository.Impl;

import com.caliverse.admin.domain.entity.EFilterOperator;
import com.caliverse.admin.dynamodb.domain.doc.BlockUserDoc;
import com.caliverse.admin.dynamodb.dto.PageResult;
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
import com.caliverse.admin.dynamodb.repository.BlockUserRepository;
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
import com.caliverse.admin.mongodb.service.DynamodbHistoryLogService;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;

import java.util.Map;


@Component
@Slf4j
public class BlockUserRepositoryImpl extends BaseDynamoDBRepository<BlockUserDoc> implements BlockUserRepository {
    public BlockUserRepositoryImpl(DynamoDBOperations operations, DynamodbHistoryLogService dynamodbHistoryLogService, ObjectMapper objectMapper) {
        super(operations, BlockUserDoc.class, dynamodbHistoryLogService, objectMapper);
    }

    @Override
    public PageResult<BlockUserDoc> getBlockUserListWithPaging(
            String userGuid,
            String sortKeyPrefix,
            String filterAttributeName,
            EFilterOperator filterOperator,
            String filterAttributeValue,
            Map<String, AttributeValue> exclusiveStartKey,
            boolean sortIndex
    ) {

        String pk = DynamoDBConstants.PK_KEY_BLOCK_USER + userGuid;;

        return findByPaging(
                pk,
                sortKeyPrefix,
                filterAttributeName,
                filterOperator,
                filterAttributeValue,
                exclusiveStartKey,
                sortIndex
        );
    }
}
