package com.yzt.airconditionersystem.controller;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParser;
import com.yzt.airconditionersystem.bean.Operator;
import com.yzt.airconditionersystem.result.Result;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.json.GsonJsonParser;
import org.springframework.http.converter.json.GsonBuilderUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @author TzZach
 * @since 2022-04-14 0:22
 */
@Controller
public class WebController {

//    @Autowired
//    private MessageChannel mqttOutboundChannel;

    @GetMapping("/unicode")
    public String unicode() {
        return "unicode";
    }

    @GetMapping("/member-list")
    public String memberList() {
        return "member-list";
    }

    @GetMapping("/blank")
    public String blank() {
        return "blank";
    }

    @GetMapping("/echarts1")
    public String echarts1() {
        return "echarts1";
    }

    @GetMapping("/echarts2")
    public String echarts2() {
        return "echarts2";
    }

    @GetMapping("/echarts3")
    public String echarts3() {
        return "echarts4";
    }

    @GetMapping("/echarts5")
    public String echarts5() {
        return "echarts5";
    }

    @GetMapping("/echarts6")
    public String echarts6() {
        return "echarts6";
    }

    @GetMapping("/echarts7")
    public String echarts7() {
        return "echarts7";
    }

    @GetMapping("/echarts8")
    public String echarts8() {
        return "echarts8";
    }

//    @GetMapping("/send/{msg}")
//    @ResponseBody
//    public Result sendMsg(@PathVariable("msg") String msg) {
//        System.out.println(msg);
//        Operator operator = new Operator(1, "张三", "张三公司", "广东省广州市", "海珠区", "联系人就是张三", "1329852852");
//        Gson gson = new GsonBuilder().create();
//        String json = gson.toJson(operator);
//        Message<String> message = new Message<String>() {
//            @Override
//            public String getPayload() {
//                return json;
//            }
//
//            @Override
//            public MessageHeaders getHeaders() {
//                Map<String, Object> map = new HashMap<>(1);
//                map.put("message", msg);
//                return new MessageHeaders(map);
//            }
//        };
//        mqttOutboundChannel.send(message);
//        return Result.success(msg);
//    }


}
