commit
d37bf272aa
|
@ -54,7 +54,7 @@ public class PageBuilder {
|
|||
Map<String,String> sortMap = pageRequest.getSortMap();
|
||||
if (CollUtil.isNotEmpty(sortMap)){
|
||||
sortMap.forEach((k,v) -> {
|
||||
orders.add(new Order(Direction.ASC, k));
|
||||
orders.add(new Order(Direction.fromString("desc"), k));
|
||||
});
|
||||
}
|
||||
return orders;
|
||||
|
|
|
@ -52,19 +52,13 @@ public class JavaScriptEngine implements IScriptEngine {
|
|||
public <T> T invokeMethod(TypeReference<T> type, String methodName, Object... args) {
|
||||
Value member = jsScript.getMember("invoke");
|
||||
|
||||
StringBuilder sbArgs = new StringBuilder("[");
|
||||
//将入参转成json
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
args[i] = JsonUtils.toJsonString(args[i]);
|
||||
sbArgs.append(i == args.length - 1 ? "," : "").append(args[i]);
|
||||
}
|
||||
sbArgs.append("]");
|
||||
StringBuilder sbArgs = formatArgs(args);
|
||||
|
||||
//通过调用invoke方法将目标方法返回结果转成json
|
||||
Value rst = member.execute(methodName, args);
|
||||
|
||||
String json = rst.asString();
|
||||
log.info("invoke script {},args:{}, result:{}", methodName, sbArgs, json);
|
||||
log.info("invoke script={}, args={}, result={}", methodName, sbArgs, json);
|
||||
|
||||
//没有返回值
|
||||
if (json == null || "null".equals(json)) {
|
||||
|
@ -74,4 +68,15 @@ public class JavaScriptEngine implements IScriptEngine {
|
|||
return JsonUtils.parseObject(json, type);
|
||||
}
|
||||
|
||||
private static StringBuilder formatArgs(Object[] args) {
|
||||
StringBuilder sbArgs = new StringBuilder("[");
|
||||
//将入参转成json
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
args[i] = JsonUtils.toJsonString(args[i]);
|
||||
sbArgs.append(args[i]).append(i != args.length - 1 ? "," : "");
|
||||
}
|
||||
sbArgs.append("]");
|
||||
return sbArgs;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package cc.iotkit.manager.dto.vo.ruleinfo;
|
||||
|
||||
import cc.iotkit.model.rule.RuleInfo;
|
||||
import cc.iotkit.model.rule.RuleLog;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
@ -10,27 +10,23 @@ import java.io.Serializable;
|
|||
|
||||
@ApiModel(value = "RuleLogVo")
|
||||
@Data
|
||||
@AutoMapper(target = RuleInfo.class)
|
||||
@AutoMapper(target = RuleLog.class)
|
||||
public class RuleLogVo implements Serializable {
|
||||
private static final long serialVersionUID = -1L;
|
||||
|
||||
@ApiModelProperty(value = "时间")
|
||||
private Long time;
|
||||
private Long logAt;
|
||||
|
||||
@ApiModelProperty(value = "规则id")
|
||||
|
||||
private String ruleId;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
|
||||
private String state1;
|
||||
private String state;
|
||||
|
||||
@ApiModelProperty(value = "内容")
|
||||
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "是否成功")
|
||||
|
||||
private Boolean success;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue