From 9c38da871a8f145a759471b8e03989eb2bce2d5c Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Sat, 19 Feb 2022 15:02:12 +0800 Subject: [PATCH] =?UTF-8?q?[alerter,common]fixbug=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=85=B3=E8=81=94=E7=9B=91=E6=8E=A7=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E6=97=B6=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/usthe/alert/controller/AlertDefineController.java | 2 ++ .../usthe/common/entity/alerter/AlertDefineMonitorBind.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/alerter/src/main/java/com/usthe/alert/controller/AlertDefineController.java b/alerter/src/main/java/com/usthe/alert/controller/AlertDefineController.java index 33a07bb..200e23c 100644 --- a/alerter/src/main/java/com/usthe/alert/controller/AlertDefineController.java +++ b/alerter/src/main/java/com/usthe/alert/controller/AlertDefineController.java @@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; import java.util.List; +import java.util.stream.Collectors; import static com.usthe.common.util.CommonConstants.MONITOR_NOT_EXIST_CODE; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @@ -94,6 +95,7 @@ public class AlertDefineController { public ResponseEntity>> getAlertDefineMonitorsBind( @ApiParam(value = "告警定义ID", example = "6565463543") @PathVariable("alertDefineId") long alertDefineId) { List defineBinds = alertDefineService.getBindAlertDefineMonitors(alertDefineId); + defineBinds = defineBinds.stream().filter(item -> item.getMonitor() != null).collect(Collectors.toList()); return ResponseEntity.ok(new Message<>(defineBinds)); } diff --git a/common/src/main/java/com/usthe/common/entity/alerter/AlertDefineMonitorBind.java b/common/src/main/java/com/usthe/common/entity/alerter/AlertDefineMonitorBind.java index 49d9a52..7aaee70 100644 --- a/common/src/main/java/com/usthe/common/entity/alerter/AlertDefineMonitorBind.java +++ b/common/src/main/java/com/usthe/common/entity/alerter/AlertDefineMonitorBind.java @@ -7,6 +7,8 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import javax.persistence.Column; import javax.persistence.Entity; @@ -58,5 +60,6 @@ public class AlertDefineMonitorBind { @OneToOne(fetch = FetchType.EAGER) @JoinColumn(name = "monitor_id", referencedColumnName = "id", insertable = false, updatable = false) + @NotFound(action = NotFoundAction.IGNORE) private Monitor monitor; }