package cokr.xit.ens.modules.ktsigntalk.gibis.service;

import cokr.xit.ens.core.aop.EnsResponseVO;
import cokr.xit.ens.modules.ktsigntalk.gibis.domain.repository.SendDetailKtGibisReqHistRepository;
import cokr.xit.ens.modules.ktsigntalk.gibis.domain.repository.SendDetailKtGibisStatHistRepository;
import cokr.xit.ens.modules.ktsigntalk.gibis.domain.repository.SendDetailKtGibisTokenHistRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RequiredArgsConstructor
public class KtGibisHisService {
    private final SendDetailKtGibisReqHistRepository sendDetailKtGibisReqHistRepository;
    private final SendDetailKtGibisTokenHistRepository sendDetailKtGibisTokenHistRepository;
    private final SendDetailKtGibisStatHistRepository sendDetailKtGibisStatHistRepository;


    /**
     * 전송요청이력 영구 삭제
     *
     * @return
     */
    public EnsResponseVO<Long> truncateReqHist() {
        Long totCnt = sendDetailKtGibisReqHistRepository.count();
        sendDetailKtGibisReqHistRepository.truncate();

        return EnsResponseVO.<Long>okBuilder()
                .resultInfo(totCnt)
                .build();
    }

    /**
     * 토큰검증요청이력 영구 삭제
     *
     * @return
     */
    public EnsResponseVO<Long> truncateTokenHist() {
        Long totCnt = sendDetailKtGibisTokenHistRepository.count();
        sendDetailKtGibisTokenHistRepository.truncate();

        return EnsResponseVO.<Long>okBuilder()
                .resultInfo(totCnt)
                .build();
    }

    /**
     * 상태변경요청이력 영구 삭제
     *
     * @return
     */
    public EnsResponseVO<Long> truncateStatHist() {
        Long totCnt = sendDetailKtGibisStatHistRepository.count();
        sendDetailKtGibisStatHistRepository.truncate();

        return EnsResponseVO.<Long>okBuilder()
                .resultInfo(totCnt)
                .build();
    }


}
