|
@@ -1,7 +1,9 @@
|
|
|
package com.zhongshu.iot.server.core.controller;
|
|
package com.zhongshu.iot.server.core.controller;
|
|
|
|
|
|
|
|
|
|
+import com.github.microservice.core.util.script.GroovyUtil;
|
|
|
import com.zhongshu.iot.client.model.mqtt.SendMessageModel;
|
|
import com.zhongshu.iot.client.model.mqtt.SendMessageModel;
|
|
|
import com.zhongshu.iot.server.core.service.artemis.OperationMessageService;
|
|
import com.zhongshu.iot.server.core.service.artemis.OperationMessageService;
|
|
|
|
|
+import com.zhongshu.iot.server.core.service.groovy.GroovySupport;
|
|
|
import com.zhongshu.iot.server.core.service.iot.IotServiceImpl;
|
|
import com.zhongshu.iot.server.core.service.iot.IotServiceImpl;
|
|
|
import com.zhongshu.iot.server.core.service.mqtt.DeviceInfoService;
|
|
import com.zhongshu.iot.server.core.service.mqtt.DeviceInfoService;
|
|
|
import com.zhongshu.iot.server.core.service.openApi.OpenAPIRegisterService;
|
|
import com.zhongshu.iot.server.core.service.openApi.OpenAPIRegisterService;
|
|
@@ -9,6 +11,7 @@ import com.zhongshu.iot.server.core.service.other.ScanExecuteService;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -16,6 +19,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
*
|
|
*
|
|
|
*/
|
|
*/
|
|
@@ -23,6 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@RestController
|
|
@RestController
|
|
|
@Validated
|
|
@Validated
|
|
|
@Tag(name = "测试接口")
|
|
@Tag(name = "测试接口")
|
|
|
|
|
+@Slf4j
|
|
|
public class TestController {
|
|
public class TestController {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -40,6 +47,9 @@ public class TestController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private DeviceInfoService deviceInfoService;
|
|
private DeviceInfoService deviceInfoService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private GroovySupport groovySupport;
|
|
|
|
|
+
|
|
|
@Operation(summary = "发送指令")
|
|
@Operation(summary = "发送指令")
|
|
|
@RequestMapping(value = "free/sendMessage", method = {RequestMethod.POST})
|
|
@RequestMapping(value = "free/sendMessage", method = {RequestMethod.POST})
|
|
|
public ResultContent sendMessage(@RequestBody SendMessageModel param) {
|
|
public ResultContent sendMessage(@RequestBody SendMessageModel param) {
|
|
@@ -78,5 +88,18 @@ public class TestController {
|
|
|
return deviceInfoService.initSyncAllDevice();
|
|
return deviceInfoService.initSyncAllDevice();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Operation(summary = "Groovy测试")
|
|
|
|
|
+ @RequestMapping(value = "testGroovy", method = {RequestMethod.GET})
|
|
|
|
|
+ public ResultContent testGroovy() {
|
|
|
|
|
+ String template = "Hi, ${name} 我的名字是:${app.getName()} ${app.getCurrentTime()}";
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> var = new HashMap<String, Object>();
|
|
|
|
|
+ var.put("name", "张三");
|
|
|
|
|
+ var.put("app", groovySupport);
|
|
|
|
|
+ String templateStr = GroovyUtil.textTemplate(var, template);
|
|
|
|
|
+ log.info("templateStr: {}", templateStr);
|
|
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|