NotSpeakJob.java 1.14 KB
package com.cnlive.shenhe.job;

import com.cnlive.shenhe.entity.ShyNotspeak;
import com.cnlive.shenhe.service.NotspeakService;
import com.cnlive.shenhe.utils.CommonConst;
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 java.util.List;

/**
 * @author Administrator
 */
@Component
public class NotSpeakJob {

    private static Logger logger = LoggerFactory.getLogger(NotSpeakJob.class);
    @Autowired
    NotspeakService notSpeakService;

    /**
     * 自动解除禁言
     * 每分钟一次
     */
    @Scheduled(cron = "0 0/1 * * * ? ")
    public void autoRetReceive() {
        List<ShyNotspeak> shyNotspeakList = notSpeakService.getNotSpeakByTime();
        if (shyNotspeakList.size() > 0) {
            for (ShyNotspeak shyNotspeak : shyNotspeakList) {
                logger.info("自动解除禁言的的speak_id:" + shyNotspeak.getId());
                notSpeakService.speak(shyNotspeak.getId(), CommonConst.SPEAK_YES, 0, null);
            }
        }
    }
}