فهرست منبع

fix 新增规则引擎

18339543638 3 سال پیش
والد
کامیت
55f237c55b

+ 12 - 2
jetlinks-manager/rule-engine-manager/src/main/java/org/jetlinks/community/rule/engine/web/RuleInstanceController.java

@@ -1,5 +1,6 @@
 package org.jetlinks.community.rule.engine.web;
 
+import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
@@ -10,6 +11,7 @@ import lombok.Setter;
 import org.hswebframework.web.api.crud.entity.PagerResult;
 import org.hswebframework.web.api.crud.entity.QueryOperation;
 import org.hswebframework.web.api.crud.entity.QueryParamEntity;
+import org.hswebframework.web.authorization.Authentication;
 import org.hswebframework.web.authorization.annotation.Authorize;
 import org.hswebframework.web.authorization.annotation.QueryAction;
 import org.hswebframework.web.authorization.annotation.Resource;
@@ -107,8 +109,16 @@ public class RuleInstanceController implements ReactiveServiceCrudController<Rul
     @ResourceAction(id = "update", name = "更新规则")
     @Operation(summary = "更新规则")
     public Mono<Boolean> update(@RequestBody RuleInstanceEntity instance) {
-        return instanceService.update(instance)
-            .thenReturn(true);
+        return Authentication.currentReactive().
+            doOnNext(auth->{
+                if(StrUtil.isNotEmpty(instance.getId())){
+                    applyModifierEntity(auth,instance);
+                }else {
+                    applyCreationEntity(auth,instance);
+                }
+            })
+            .then( instanceService.update(instance)
+                .thenReturn(true));
     }
 
     @GetMapping("/{id}/logs")