All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.lastwhisper.trace.event.CascadeIdNotifier Maven / Gradle / Ivy

The newest version!
package cn.lastwhisper.trace.event;

import cn.lastwhisper.trace.model.RealVo;
import cn.lastwhisper.trace.repository.RealTraceRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * 事件消息接收者
 * @author lastwhisper
 * @date 2020/4/8
 */
@Component
public class CascadeIdNotifier {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private RealTraceRepository realTraceRepository;

    public void setRealTraceRepository(RealTraceRepository realTraceRepository) {
        this.realTraceRepository = realTraceRepository;
    }

    @EventListener(classes = {CascadeEvent.class})
    public void processCascadeEvent(CascadeEvent event) {
        logger.debug("receive cascade event");
        List idList = event.getIdList();
        Set realVoList = idList.stream().map(RealVo::new).collect(Collectors.toSet());
        realTraceRepository.removePage(realVoList);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy