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

import com.caliverse.admin.domain.entity.EFilterOperator;
import com.caliverse.admin.dynamodb.domain.doc.FriendDoc;
import com.caliverse.admin.dynamodb.dto.PageResult;
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
import com.caliverse.admin.dynamodb.repository.FriendRepository;
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 FriendRepositoryImpl extends BaseDynamoDBRepository<FriendDoc> implements FriendRepository {
    public FriendRepositoryImpl(DynamoDBOperations operations, DynamodbHistoryLogService dynamodbHistoryLogService, ObjectMapper objectMapper) {
        super(operations, FriendDoc.class, dynamodbHistoryLogService, objectMapper);
    }

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

        String pk = DynamoDBConstants.PK_KEY_FRIEND + userGuid;;

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