package com.xhpc.pp.server;


import com.xhpc.common.util.DateUtil;
import com.xhpc.pp.mapper.XhpcMessageMapper;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

@Component
public class MessageCLeanTask {

    @Resource
    XhpcMessageMapper messageMapper;

    /**
     * 每天定时清理message表三个月前的数据
     */
    @Scheduled(cron = "0 0 05 1/1 * ?")
    private void run(){

        String expireDate = DateUtil.date2String(DateUtil.addDay(new Date(), -90), DateUtil.DATE_FORMAT_DATE_TIME) ;
        messageMapper.deleteByLastThreeMonth(expireDate);

    }
}
