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

import com.caliverse.admin.domain.entity.EFilterOperator;
import com.caliverse.admin.domain.entity.HISTORYTYPEDETAIL;
import com.caliverse.admin.dynamodb.domain.atrrib.ItemAttrib;
import com.caliverse.admin.dynamodb.domain.doc.ItemDoc;
import com.caliverse.admin.dynamodb.domain.doc.MyhomeDoc;
import com.caliverse.admin.dynamodb.dto.PageResult;
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
import com.caliverse.admin.dynamodb.repository.ItemRepository;
import com.caliverse.admin.dynamodb.repository.MyHomeRepository;
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
import com.caliverse.admin.global.common.code.CommonCode;
import com.caliverse.admin.global.common.code.ErrorCode;
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
import com.caliverse.admin.global.common.exception.RestApiException;
import com.caliverse.admin.global.common.utils.CommonUtils;
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.enhanced.dynamodb.Key;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;

import java.time.LocalDateTime;
import java.util.Map;


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

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

        String pk = DynamoDBConstants.PK_KEY_MY_HOME + userGuid;;

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