package com.bb.service;

import com.bb.dao.CreditDao;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
@RequiredArgsConstructor
@Slf4j
public class PointAsyncService {

    private final CreditDao creditDao;

    @Async("pointTaskExecutor")
    public void processPointAsync(HashMap<String, Object> pointParam, String methodName, String tranId) {
        try {
            log.info("[{}]::{} pointParam::{}", tranId, methodName, pointParam.toString());
            creditDao.insertCreditPoint(pointParam);
            log.info("[{}]::{} creditDao.insertCreditPoint() completed", tranId, methodName);
        } catch (Exception e) {
            log.error("[{}]::{} Exception::{}", tranId, methodName, e.getMessage());
        }
    }
}
