TopicJob.java 1.54 KB
package com.cnlive.shenhe.job;

import com.cnlive.shenhe.entity.ShyTopic;
import com.cnlive.shenhe.service.TopicService;
import com.cnlive.shenhe.utils.CommonConst;
import com.cnlive.shenhe.utils.InfoUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: xujincheng
 * @Date: 2020/3/13 15:47
 */

@Component
public class TopicJob {

    private static Logger logger = LoggerFactory.getLogger(TopicJob.class);
    @Autowired
    TopicService topicService;
    @Autowired
    InfoUtil infoUtil;
    @Value("${spring.localhost.url}")
    private String localhost_url;

    //@Scheduled(cron = "0 0/5 * * * ?")
    public void topicNotice() {
        ShyTopic shyTopic = new ShyTopic();
        shyTopic.setShenhe_status(CommonConst.AUDIT_INTT);
        shyTopic.setShenhe_type(CommonConst.AUDIT_TYPE_USER);
        List<ShyTopic> shyTopicList = topicService.findShyTopic(shyTopic);
        if (shyTopicList != null && shyTopicList.size() > 0) {
            logger.info("您有" + shyTopicList.size() + "条新的话题审核,请注意查看!");
            // 设置Headless模式,linux系统下
            System.setProperty("java.awt.headless", "true");
            infoUtil.show("新话题审核", "您有" + shyTopicList.size() + "条新的话题审核,请注意查看!", localhost_url + "/topic/page?shenhe_status=0&receive=0");
        }
    }
}