package org.springblade.third.doordevice.consume;

import com.alibaba.fastjson.JSONObject;
import org.springblade.common.beans.ApiResultBean;
import org.springblade.third.doordevice.conf.QinLinMqConf;
import org.springblade.third.doordevice.entity.qinlin.QLinUserDevice;
import org.springblade.third.doordevice.utils.QinLinHttpUtil;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

/**
 * @author lidexi
 * @date 2021/5/25 10:26
 */
@Component
public class QinLinMqConsumer {

	private final  static String QUEUENAME ="qinlin";

	private QinLinHttpUtil qinLinHttpUtil;

	public QinLinMqConsumer(QinLinHttpUtil qinLinHttpUtil){
		this.qinLinHttpUtil = qinLinHttpUtil;
	}

	/*@RabbitHandler
	@RabbitListener(queues = QUEUENAME,containerFactory = "qinlinListenerFactory")
	public void queueListen(Message message){
		JSONObject map = JSONObject.parseObject(new String(message.getBody(), StandardCharsets.UTF_8));
		String instruct = map.get("instruct").toString();
		switch (instruct){
			case "open_door":
				//构建远程开门对象
				QLinUserDevice qLinUserDevice = new QLinUserDevice();
				qLinUserDevice.setDeviceId(map.get("deviceId").toString());
				qLinUserDevice.setUserId(map.get("userId").toString());
				//发送远程开门指令
				qinLinHttpUtil.remoteOpenDoor(qLinUserDevice);
				break;
		}


	}*/
}
