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;
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.actions.ActionResult;
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.PropertySet;
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.stereotype.Service;
@ -30,54 +27,17 @@ public class HttpDevice implements IDevice {
@Override
public ActionResult propertyGet(PropertyGet action) {
String topic = String.format("/sys/%s/%s/c/service/property/get", action.getProductKey(), action.getDeviceName());
return send(
topic,
action.getDeviceName(),
new JsonObject()
.put("id", action.getId())
.put("method", "thing.service.property.get")
.put("params", action.getKeys())
.toString()
);
throw new UnsupportedOperationException("不支持该功能");
}
@Override
public ActionResult propertySet(PropertySet action) {
String topic = String.format("/sys/%s/%s/c/service/property/set", action.getProductKey(), action.getDeviceName());
return send(
topic,
action.getDeviceName(),
new JsonObject()
.put("id", action.getId())
.put("method", "thing.service.property.set")
.put("params", action.getParams())
.toString()
);
throw new UnsupportedOperationException("不支持该功能");
}
@Override
public ActionResult serviceInvoke(ServiceInvoke action) {
String topic = String.format("/sys/%s/%s/c/service/%s", action.getProductKey(), action.getDeviceName(), action.getName());
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();
}
throw new UnsupportedOperationException("不支持该功能");
}
}

View File

View File

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

View File

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