package com.muyu.vehiclegateway.controller;

import com.alibaba.fastjson2.JSONObject;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.uuid.UUID;
import com.muyu.vehiclegateway.domain.Instance;

import com.muyu.vehiclegateway.domain.MqttServerModel;
import com.muyu.vehiclegateway.domain.req.VehicleConnectionReq;
import com.muyu.vehiclegateway.service.VehicleGatewayService;
import lombok.extern.log4j.Log4j2;
import org.eclipse.paho.client.mqttv3.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: WangXin
 * @name：VehicleGatewayController
 * @Date：2024/9/25 21:05
 */
@Log4j2
@RestController
@RequestMapping("/vehicleGateway")
public class VehicleGatewayController {

    @Autowired
    private VehicleGatewayService vehicleGatewayService;

    @PostMapping("/receiveMsg/connect")
    public Result receiveMsg(@RequestBody VehicleConnectionReq vehicleConnectionReq){
        log.info("=======>"+vehicleConnectionReq);
       MqttServerModel mqttServerModel = vehicleGatewayService.receiveMsg(vehicleConnectionReq);


        return Result.success(mqttServerModel);
    }

//    @PostMapping("/testConnect")
//    public void testConnect() {
//        vehicleGatewayService.testConnect();
//    }





}
