package com.eactive.eai.rms.bat.common.service;

import java.time.LocalDateTime;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service("batLogTableDeleteService")
public class BatLogTableDeleteService {

    @Autowired
    @Qualifier("batLogTableDao")
    private BatLogTableDao batLogTableDao;
    
    public long [] clearLogTable(HashMap<String, String> paramMap, int keyLevel) {
    	return batLogTableDao.clearLogTable(paramMap, keyLevel);
    }

    public int delete(Period remain) {
		
		String dateTime = LocalDateTime.now()
				.minusDays(remain.getDays())
				.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"));
		
		return batLogTableDao.delete(new HashMap<String, Object>() {{
			put("dateTime", dateTime);
		}});
	}
    
}
