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

import cokr.xit.ens.core.aop.EnsResponseVO;
import cokr.xit.ens.modules.ktsigntalk.direct.domain.repository.SendDetailKtSigntalkReqHistRepository;
import cokr.xit.ens.modules.ktsigntalk.direct.domain.repository.SendDetailKtSigntalkStatHistRepository;
import cokr.xit.ens.modules.ktsigntalk.direct.domain.repository.SendDetailKtSigntalkTokenHistRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RequiredArgsConstructor
public class KtSigntalkHisService {
    private final SendDetailKtSigntalkReqHistRepository sendDetailKtSigntalkReqHistRepository;
    private final SendDetailKtSigntalkTokenHistRepository sendDetailKtSigntalkTokenHistRepository;
    private final SendDetailKtSigntalkStatHistRepository sendDetailKtSigntalkStatHistRepository;


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

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

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

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

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

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


}
