Skip to content

Commit

Permalink
fix(告警记录): 添加通过告警配置Id查询告警日志接口 (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
bestfeng1020 authored Jun 17, 2024
1 parent 7e24f3d commit 8515c9b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public SqlFragments createFragments(String columnFullName,
sqlFragments
.addSql(
"and _bind.rule_id in (",
String.join("?", bindTerm.ruleId),
bindTerm.ruleId.stream().map(r -> "?").collect(Collectors.joining(",")),
")")
.addParameter(bindTerm.ruleId);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jetlinks.community.rule.engine.web;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.hswebframework.web.api.crud.entity.PagerResult;
Expand All @@ -10,10 +11,7 @@
import org.hswebframework.web.authorization.annotation.Resource;
import org.jetlinks.community.rule.engine.entity.AlarmHistoryInfo;
import org.jetlinks.community.rule.engine.service.AlarmHistoryService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

@RestController
Expand All @@ -29,8 +27,24 @@ public class AlarmHistoryController {
@PostMapping("/_query")
@Operation(summary = "告警历史查询")
@QueryAction
@Deprecated
public Mono<PagerResult<AlarmHistoryInfo>> queryHandleHistoryPager(@RequestBody Mono<QueryParamEntity> query) {
return query.flatMap(alarmHistoryService::queryPager);
}

@PostMapping("/{alarmConfigId}/_query")
@Operation(summary = "告警历史查询")
@QueryAction
public Mono<PagerResult<AlarmHistoryInfo>> queryHandleHistoryPager(
@PathVariable @Parameter(description = "告警配置ID") String alarmConfigId,
@RequestBody Mono<QueryParamEntity> query
) {
return query
.map(q -> q
.toNestQuery()
.and(AlarmHistoryInfo::getAlarmConfigId, alarmConfigId)
.getParam())
.flatMap(alarmHistoryService::queryPager);
}

}

0 comments on commit 8515c9b

Please sign in to comment.