1、解决指令按条件查询总数bug

2、动态、静态规则新增批量查询功能
This commit is contained in:
Hao Miao
2024-01-23 23:26:15 +08:00
parent 389483989c
commit 31277b7246
11 changed files with 104 additions and 36 deletions

View File

@@ -81,7 +81,6 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
@Override
@GetMapping("/{id}/query")
public ResponseResult queryDynamicRuleObjectById(@PathVariable Integer id) {
log.info("查询动态规则: {}", id);
DynamicRuleObject dynamicRuleObject = dynamicRuleService.queryDynamicRuleById(id);
//调用service查询
return ResponseResult.ok()
@@ -89,6 +88,16 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
.setData("dynamic_rule", dynamicRuleObject);
}
@Override
@GetMapping("/query/{ids}")
public ResponseResult queryDynamicRuleObjectByIds(@PathVariable List<Integer> ids) {
List<DynamicRuleObject> dynamicRuleObjects = dynamicRuleService.queryDynamicRuleByIds(ids);
//调用service查询
return ResponseResult.ok()
.setData("success", true)
.setData("dynamic_rule", dynamicRuleObjects);
}
//分页查询
@Override
@GetMapping("/query")

View File

@@ -10,6 +10,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@@ -186,6 +187,24 @@ public interface DynamicRuleControllerApi {
)
public ResponseResult queryDynamicRuleObjectById(@PathVariable Integer id) ;
@Operation(
summary = "查询多个动态规则",
description = "根据条件查询多个动态规则",
responses = {
@ApiResponse(
description = "返回查询到的多个动态规则",
content = @Content(
mediaType = "application/json",
schema = @Schema(
title = "ResponseResult和DynamicRule的组合模型",
description = "ResponseResult的data内DynamicRule",
anyOf = {ResponseResult.class, DynamicRuleObject.class})
))},
parameters = {@Parameter(name = "ids", description = "动态规则ID列表", example = "dynamicrule/query/5,11")}
)
@GetMapping("/query/{ids}")
ResponseResult queryDynamicRuleObjectByIds(@PathVariable List<Integer> ids);
@Operation(
summary = "根据条件查询多个动态规则",
description = "根据查询条件和页码等,查询多个对象并以列表返回",

View File

@@ -43,4 +43,6 @@ public interface DynamicRuleMapper {
Integer queryDynamicRuleTotalNum(String dynamicRuleName, Integer dynamicRuleId,
String sourceSystem, String creator);
List<DynamicRuleObject> queryDynamicRuleByIds(List<Integer> ids);
}

View File

@@ -166,4 +166,8 @@ public class DynamicRuleService {
return dynamicRuleMapper.queryDynamicRuleTotalNum(dynamicRuleName, dynamicRuleId,
protectObjectSourceSystem, creator);
}
public List<DynamicRuleObject> queryDynamicRuleByIds(List<Integer> ids) {
return dynamicRuleMapper.queryDynamicRuleByIds(ids);
}
}

View File

@@ -143,6 +143,16 @@ public class StaticRuleController implements StaticRuleControllerApi {
static_rule_creator, static_rule_ip));
}
@Override
@GetMapping("/query/{ids}")
public ResponseResult queryStaticRuleByIds(@PathVariable List<Integer> ids) {
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRuleByIds(ids);
//调用service查询
return ResponseResult.ok()
.setData("success", true)
.setData("static_rule", staticRuleObjects);
}
/**
* 修改审核状态
*/

View File

@@ -10,10 +10,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
@@ -213,6 +210,24 @@ public interface StaticRuleControllerApi {
);
@Operation( summary = "批量查询静态规则",
description = "根据静态规则ID列表查询多个静态规则的所有详细信息",
responses = {
@io.swagger.v3.oas.annotations.responses.ApiResponse(
description = "返回查询到的多个静态规则",
content = @Content(
mediaType = "application/json",
schema = @Schema(title = "ResponseResult和StaticRule的对象属性",
anyOf = {ResponseResult.class, StaticRuleObject.class})
)
)
},
parameters = {@Parameter(name = "ids", description = "静态规则ID列表", example = "staticrule/query/15,16,17")}
)
@GetMapping("/query/{ids}")
ResponseResult queryStaticRuleByIds(@PathVariable List<Integer> ids);
@Operation(
summary = "按id删除静态规则",
description = "按id删除静态规则",
@@ -240,6 +255,8 @@ public interface StaticRuleControllerApi {
@Operation(
summary = "更新静态规则审批状态",
description = "更新静态规则审批状态0未审核、1审核不通过、2审核通过",

View File

@@ -41,4 +41,6 @@ public interface StaticRuleMapper {
Integer queryStaticRuleTotalNum(String static_rule_name, Integer static_rule_id,
String static_rule_create_username, String ip);
List<StaticRuleObject> queryStaticRuleByIds(List<Integer> ids);
}

View File

@@ -153,4 +153,8 @@ public class StaticRuleService {
return staticRuleMapper.queryStaticRuleTotalNum(static_rule_name, static_rule_id,
static_rule_creator, static_rule_ip);
}
public List<StaticRuleObject> queryStaticRuleByIds(List<Integer> ids) {
return staticRuleMapper.queryStaticRuleByIds(ids);
}
}