
package sgc.portal.com.sym.batch.service;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import sgc.portal.base.storage.service.StorageService;
/**
 * The type Authentication exception.
 *
 * @author YongSang
 * @version 1.0.0
 * @since 2020. 7. 28.
 */
@Component
public class FileBatchService {

    /**
	 * 첨부파일 물리 삭제
	 */
    
	@Autowired
	private StorageService storageService;
	
    Logger logger = LoggerFactory.getLogger(this.getClass());
    //logger.info("[MYTEST] test batch {}", recvAddress);
    
    
    @Scheduled(cron = "0 0 5 * * *")		//5시 실행
    //@Scheduled(cron = "0/10 * * * * *")	//10초마다 실행
    public void schedule() throws Exception {
    	SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        Calendar c1 = Calendar.getInstance();
    	String date = sdf.format(c1.getTime());
    	storageService.deleteAll(date);
    }
    
}