package com.njcn.energy.controller;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil;
import com.njcn.energy.service.IModelService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2022/2/28 10:55
 */
@Slf4j
@RestController
@RequestMapping("/interact")
@AllArgsConstructor
@Api(tags = "交互功能管理")
public class ModelController extends BaseController {

    private final IModelService modelService;

    @PostMapping("/deviceRegister")
    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @ApiOperation("联网装置注册请求")
    @ApiImplicitParam(name = "json", value = "mqtt数据", required = true)
    public HttpResult<String> deviceRegister(String json){
        String methodDescribe = getMethodDescribe("deviceRegister");
        LogUtil.njcnDebug(log, "{}，mqtt数据：{}", methodDescribe, json);
        String result = modelService.deviceRegister(json);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

//    @PostMapping("/deviceAccess")
//    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
//    @ApiOperation("设备接入")
//    @ApiImplicitParam(name = "json", value = "mqtt数据", required = true)
//    public HttpResult<String> deviceAccess(String json){
//        String methodDescribe = getMethodDescribe("deviceAccess");
//        LogUtil.njcnDebug(log, "{}，mqtt数据：{}", methodDescribe, json);
//        String result = modelService.deviceAccess(json);
//        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
//    }

    @PostMapping("/deviceData")
    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @ApiOperation("设备数据(模板)")
    @ApiImplicitParam(name = "json", value = "mqtt数据", required = true)
    public HttpResult<String> deviceData(String json){
        String methodDescribe = getMethodDescribe("deviceData");
        LogUtil.njcnDebug(log, "{}，mqtt数据：{}", methodDescribe, json);
        String result = modelService.deviceData(json);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }


}
