package com.caliverse.admin.dynamodb.service;

import com.caliverse.admin.global.common.annotation.DynamoDBTransaction;
import com.caliverse.admin.dynamodb.repository.CaliumStorageRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
@Slf4j
public class DynamodbCaliumService {
    private final CaliumStorageRepository caliumStorageRepository;

    public double getCaliumTotal(){
        return caliumStorageRepository.getTotal();
    }

    @DynamoDBTransaction
    public void updateCaliumTotal(double caliumCnt){
        caliumStorageRepository.updateTotal(caliumCnt);
    }

    @DynamoDBTransaction
    public void caliumStockDeduction(double caliumCnt){
        caliumStorageRepository.stockDeduction(caliumCnt);
    }
}
