package org.springblade.modules.eventbus.service.community;

import com.google.common.eventbus.Subscribe;
import com.nepxion.eventbus.annotation.EventBus;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.community.agency.dto.AgencyDTO;
import org.springblade.community.agency.entity.Agency;
import org.springblade.community.residential.dto.ResidentialDTO;
import org.springframework.stereotype.Service;


/**
 * Created By lidexi in 2021/1/2
 * 社区子线程接收异步事件处理类
 **/
@EventBus(identifier = "communitySubscriber")
@Service
public class CommunitySubscriber {
	private static final Logger LOG = LoggerFactory.getLogger(CommunitySubscriber.class);

	/**
	 *
	 * @param agency
	 */
	@Subscribe
	public void subscribe(AgencyDTO agency) throws InterruptedException {
		Integer wMethod = agency.getWMethod();
		switch (wMethod){
			case 1:
				LOG.info("子线程新增社区-{},agency",agency);
				break;
			case 2:
				LOG.info("子线程删除社区-{},agency",agency);
				//删除社区的同时删除删除该社区下所有的子集
				break;
			case 3:
				LOG.info("子线程修改社区-{},agency",agency);
				break;

		}
		Thread.sleep(2000);
		System.out.println("--------------------------1----------------------");


	}

	/**
	 *
	 * @param residentialDTO
	 */
	@Subscribe
	public void subscribe(ResidentialDTO residentialDTO){
//		Integer wMethod = agency.getWMethod();
//		switch (wMethod){
//			case 1:
//				LOG.info("子线程新增社区-{},agency",agency);
//				break;
//			case 2:
//				LOG.info("子线程删除社区-{},agency",agency);
//				break;
//			case 3:
//				LOG.info("子线程修改社区-{},agency",agency);
//				break;
//
//		}


	}
}
