fix:脚本文件名修改

master
xiwa 2023-10-27 08:10:42 +08:00
parent a7483c0ae8
commit 9550c091eb
6 changed files with 4 additions and 45 deletions

View File

@ -1,14 +1,11 @@
package cc.iotkit.plugins.http.service; package cc.iotkit.plugins.http.service;
import cc.iotkit.common.enums.ErrCode;
import cc.iotkit.common.exception.BizException;
import cc.iotkit.plugin.core.thing.IDevice; import cc.iotkit.plugin.core.thing.IDevice;
import cc.iotkit.plugin.core.thing.actions.ActionResult; import cc.iotkit.plugin.core.thing.actions.ActionResult;
import cc.iotkit.plugin.core.thing.actions.down.DeviceConfig; import cc.iotkit.plugin.core.thing.actions.down.DeviceConfig;
import cc.iotkit.plugin.core.thing.actions.down.PropertyGet; import cc.iotkit.plugin.core.thing.actions.down.PropertyGet;
import cc.iotkit.plugin.core.thing.actions.down.PropertySet; import cc.iotkit.plugin.core.thing.actions.down.PropertySet;
import cc.iotkit.plugin.core.thing.actions.down.ServiceInvoke; import cc.iotkit.plugin.core.thing.actions.down.ServiceInvoke;
import io.vertx.core.json.JsonObject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -30,54 +27,17 @@ public class HttpDevice implements IDevice {
@Override @Override
public ActionResult propertyGet(PropertyGet action) { public ActionResult propertyGet(PropertyGet action) {
String topic = String.format("/sys/%s/%s/c/service/property/get", action.getProductKey(), action.getDeviceName()); throw new UnsupportedOperationException("不支持该功能");
return send(
topic,
action.getDeviceName(),
new JsonObject()
.put("id", action.getId())
.put("method", "thing.service.property.get")
.put("params", action.getKeys())
.toString()
);
} }
@Override @Override
public ActionResult propertySet(PropertySet action) { public ActionResult propertySet(PropertySet action) {
String topic = String.format("/sys/%s/%s/c/service/property/set", action.getProductKey(), action.getDeviceName()); throw new UnsupportedOperationException("不支持该功能");
return send(
topic,
action.getDeviceName(),
new JsonObject()
.put("id", action.getId())
.put("method", "thing.service.property.set")
.put("params", action.getParams())
.toString()
);
} }
@Override @Override
public ActionResult serviceInvoke(ServiceInvoke action) { public ActionResult serviceInvoke(ServiceInvoke action) {
String topic = String.format("/sys/%s/%s/c/service/%s", action.getProductKey(), action.getDeviceName(), action.getName()); throw new UnsupportedOperationException("不支持该功能");
return send(
topic,
action.getDeviceName(),
new JsonObject()
.put("id", action.getId())
.put("method", "thing.service." + action.getName())
.put("params", action.getParams())
.toString()
);
}
private ActionResult send(String topic, String deviceName, String payload) {
try {
return ActionResult.builder().code(0).reason("").build();
} catch (BizException e) {
return ActionResult.builder().code(e.getCode()).reason(e.getMessage()).build();
} catch (Exception e) {
return ActionResult.builder().code(ErrCode.UNKNOWN_EXCEPTION.getKey()).reason(e.getMessage()).build();
}
} }
} }

View File

View File

@ -25,7 +25,7 @@ public class BeanConfig {
@Bean @Bean
@ConditionalOnProperty(name = "plugin.runMode", havingValue = "dev") @ConditionalOnProperty(name = "plugin.runMode", havingValue = "dev")
IPluginScript getPluginScript() { IPluginScript getPluginScript() {
return new LocalPluginScript("test.js"); return new LocalPluginScript("script.js");
} }
@Bean @Bean

View File

@ -8,7 +8,6 @@
<module>http-plugin</module> <module>http-plugin</module>
<module>modbus-plugin</module> <module>modbus-plugin</module>
<module>tcp-plugin</module> <module>tcp-plugin</module>
<module>tcp-plugin2</module>
</modules> </modules>
<parent> <parent>