1、静态动态规则分页查询条件新增审核状态
This commit is contained in:
@@ -108,6 +108,7 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
|
||||
@RequestParam(value = "id", required = false) Integer dynamicRuleId,
|
||||
@RequestParam(value = "source_system", required = false) String protectObjectSourceSystem,
|
||||
@RequestParam(value = "creator", required = false) String creator,
|
||||
@RequestParam(value = "audit_status", required = false) Integer auditStatus,
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "page_size", defaultValue = "10") Integer pageSize) {
|
||||
log.info("分页查询动态规则: {}:{}:{}:{}", dynamicRuleName, dynamicRuleId, page, pageSize);
|
||||
@@ -115,9 +116,9 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
|
||||
return ResponseResult.ok()
|
||||
.setData("success", true)
|
||||
.setData("dynamic_rule_list", dynamicRuleService.queryDynamicRuleObject(dynamicRuleName, dynamicRuleId,
|
||||
protectObjectSourceSystem, creator, page, pageSize))
|
||||
protectObjectSourceSystem, creator, auditStatus, page, pageSize))
|
||||
.setData("total_num",dynamicRuleService.queryDynamicRuleTotalNum(dynamicRuleName, dynamicRuleId,
|
||||
protectObjectSourceSystem, creator));
|
||||
protectObjectSourceSystem, creator, auditStatus));
|
||||
}
|
||||
|
||||
//详情查看?? 就是按id查询吧
|
||||
@@ -170,7 +171,7 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
|
||||
public ResponseResult getStaticRuleStatisticsData(){
|
||||
|
||||
return ResponseResult.ok()
|
||||
.setData("dynamic_rule_num", dynamicRuleService.queryDynamicRuleTotalNum(null, null,
|
||||
.setData("dynamic_rule_num", dynamicRuleService.queryDynamicRuleTotalNum(null,null, null,
|
||||
null, null))
|
||||
.setData("dynamic_rule_used_num", dynamicRuleService.queryAuditDynamicRuleTotalNum(
|
||||
AuditStatusEnum.getNumByState(AuditStatusEnum.USING.getState())
|
||||
|
||||
@@ -347,6 +347,7 @@ public interface DynamicRuleControllerApi {
|
||||
@Parameter(name = "id", description = "动态规则ID", example = "2"),
|
||||
@Parameter(name = "source_system", description = "来源你系统", example = "BW系统"),
|
||||
@Parameter(name = "creator", description = "创建人名称"),
|
||||
@Parameter(name = "audit_status", description = "审核状态", example = "1"),
|
||||
@Parameter(name = "page", description = "页码", example = "1"),
|
||||
@Parameter(name = "page_size", description = "每页大小", example = "10")
|
||||
}
|
||||
@@ -355,6 +356,7 @@ public interface DynamicRuleControllerApi {
|
||||
@RequestParam(value = "id", required = false) Integer dynamicRuleId,
|
||||
@RequestParam(value = "source_system", required = false) String protectObjectSourceSystem,
|
||||
@RequestParam(value = "creator", required = false) String creator,
|
||||
@RequestParam(value = "audit_status", required = false) Integer auditStatus,
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "page_size", defaultValue = "10") Integer pageSize);
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public interface DynamicRuleMapper {
|
||||
void deleteDynamicRules(List<Integer> dynamicRuleIds);
|
||||
|
||||
List<DynamicRuleObject> queryDynamicRuleObject(String dynamicRuleName, Integer dynamicRuleId,
|
||||
String sourceSystem, String creator,
|
||||
String sourceSystem, String creator, Integer auditStatus,
|
||||
Integer page, Integer pageSize);
|
||||
|
||||
void deleteDynamicRuleProtectObjectConcat(Integer dynamicRuleId);
|
||||
@@ -43,7 +43,7 @@ public interface DynamicRuleMapper {
|
||||
boolean queryProtectObjectById(Integer protectObjectId);
|
||||
|
||||
Integer queryDynamicRuleTotalNum(String dynamicRuleName, Integer dynamicRuleId,
|
||||
String sourceSystem, String creator);
|
||||
String sourceSystem, String creator, Integer auditStatus);
|
||||
|
||||
List<DynamicRuleObject> queryDynamicRuleByIds(List<Integer> ids);
|
||||
|
||||
|
||||
@@ -171,16 +171,17 @@ public class DynamicRuleService {
|
||||
|
||||
//分页查询基础的动态规则,暂时不返回关联的保护对象
|
||||
public List<DynamicRuleObject> queryDynamicRuleObject(String dynamicRuleName, Integer dynamicRuleId,
|
||||
String templateSourceSystem,String creator,
|
||||
String templateSourceSystem,String creator,Integer auditStatus,
|
||||
Integer page, Integer pageSize) {
|
||||
return dynamicRuleMapper.queryDynamicRuleObject(dynamicRuleName, dynamicRuleId,
|
||||
templateSourceSystem, creator, page, pageSize);
|
||||
templateSourceSystem, creator, auditStatus, page, pageSize);
|
||||
}
|
||||
|
||||
public Integer queryDynamicRuleTotalNum(String dynamicRuleName, Integer dynamicRuleId,
|
||||
String protectObjectSourceSystem, String creator) {
|
||||
String protectObjectSourceSystem, String creator,
|
||||
Integer auditStatus) {
|
||||
return dynamicRuleMapper.queryDynamicRuleTotalNum(dynamicRuleName, dynamicRuleId,
|
||||
protectObjectSourceSystem, creator);
|
||||
protectObjectSourceSystem, creator, auditStatus);
|
||||
}
|
||||
|
||||
public List<DynamicRuleObject> queryDynamicRuleByIds(List<Integer> ids) {
|
||||
|
||||
@@ -134,6 +134,7 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
@RequestParam(name = "id", required = false) Integer static_rule_id,
|
||||
@RequestParam(name = "creator", required = false) String static_rule_creator,
|
||||
@RequestParam(name = "ip", required = false) String static_rule_ip,
|
||||
@RequestParam(name = "auditStatus", required = false) Integer auditStatus,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize
|
||||
) {
|
||||
@@ -141,11 +142,11 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
//调用service新增
|
||||
List<StaticRuleObject> pageResult = staticRuleService.queryStaticRule(
|
||||
static_rule_name, static_rule_id,
|
||||
static_rule_creator, static_rule_ip, page, pageSize);
|
||||
static_rule_creator, static_rule_ip, auditStatus, page, pageSize);
|
||||
return ResponseResult.ok()
|
||||
.setData("static_rule_list", pageResult)
|
||||
.setData("total_num",staticRuleService.queryStaticRuleTotalNum(static_rule_name, static_rule_id,
|
||||
static_rule_creator, static_rule_ip));
|
||||
static_rule_creator, static_rule_ip, auditStatus));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,7 +209,7 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
public ResponseResult getStaticRuleStatisticsData(){
|
||||
|
||||
return ResponseResult.ok()
|
||||
.setData("static_rule_num", staticRuleService.queryStaticRuleTotalNum(null, null, null, null))
|
||||
.setData("static_rule_num", staticRuleService.queryStaticRuleTotalNum(null, null, null, null, null))
|
||||
.setData("static_rule_used_num", staticRuleService.queryAuditStaticRuleTotalNum(
|
||||
AuditStatusEnum.getNumByState(AuditStatusEnum.USING.getState())
|
||||
))
|
||||
|
||||
@@ -204,6 +204,7 @@ public interface StaticRuleControllerApi {
|
||||
@Parameter(name = "id", description = "静态规则id"),
|
||||
@Parameter(name = "creator", description = "静态规则创建人"),
|
||||
@Parameter(name = "ip", description = "静态规则ip,匹配所有源和目的ip"),
|
||||
@Parameter(name = "auditStatus", description = "静态规则审核状态"),
|
||||
@Parameter(name = "page", description = "页码"),
|
||||
@Parameter(name = "pageSize", description = "每页条数")
|
||||
}
|
||||
@@ -212,6 +213,7 @@ public interface StaticRuleControllerApi {
|
||||
@RequestParam(required = false) Integer static_rule_id,
|
||||
@RequestParam(required = false) String static_rule_creator,
|
||||
@RequestParam(required = false) String static_rule_ip,
|
||||
@RequestParam(required = false) Integer auditStatus,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize
|
||||
);
|
||||
|
||||
@@ -28,7 +28,7 @@ public interface StaticRuleMapper {
|
||||
|
||||
//多页查询静态规则
|
||||
List<StaticRuleObject> queryStaticRule(String static_rule_name, Integer static_rule_id,
|
||||
String static_rule_create_username, String ip,
|
||||
String static_rule_create_username, String ip, Integer auditStatus,
|
||||
Integer page, Integer pageSize);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface StaticRuleMapper {
|
||||
Boolean updateAuditStatusById(Integer id, Integer auditStatus);
|
||||
|
||||
Integer queryStaticRuleTotalNum(String static_rule_name, Integer static_rule_id,
|
||||
String static_rule_create_username, String ip);
|
||||
String static_rule_create_username, String ip, Integer auditStatus);
|
||||
|
||||
List<StaticRuleObject> queryStaticRuleByIds(List<Integer> ids);
|
||||
|
||||
|
||||
@@ -166,11 +166,11 @@ public class StaticRuleService {
|
||||
*/
|
||||
public List<StaticRuleObject> queryStaticRule(
|
||||
String static_rule_name, Integer static_rule_id,
|
||||
String creator, String ip,
|
||||
String creator, String ip, Integer auditStatus,
|
||||
Integer page, Integer pageSize) {
|
||||
|
||||
return staticRuleMapper.queryStaticRule(static_rule_name, static_rule_id,
|
||||
creator, ip, page, pageSize);
|
||||
creator, ip, auditStatus, page, pageSize);
|
||||
}
|
||||
|
||||
public Boolean newStaticRuleObjects(List<StaticRuleObject> staticRuleList) {
|
||||
@@ -233,9 +233,9 @@ public class StaticRuleService {
|
||||
}
|
||||
|
||||
public Integer queryStaticRuleTotalNum(String static_rule_name, Integer static_rule_id,
|
||||
String static_rule_creator, String static_rule_ip) {
|
||||
String static_rule_creator, String static_rule_ip, Integer auditStatus) {
|
||||
return staticRuleMapper.queryStaticRuleTotalNum(static_rule_name, static_rule_id,
|
||||
static_rule_creator, static_rule_ip);
|
||||
static_rule_creator, static_rule_ip, auditStatus);
|
||||
}
|
||||
|
||||
public List<StaticRuleObject> queryStaticRuleByIds(List<Integer> ids) {
|
||||
|
||||
@@ -190,18 +190,21 @@
|
||||
left join t_strategy_template
|
||||
on t_dynamic_rule.template_id = t_strategy_template.strategy_template_id
|
||||
<where>
|
||||
<if test="dynamicRuleName != null">
|
||||
<if test="dynamicRuleName != null and dynamicRuleName !=''" >
|
||||
t_dynamic_rule.dynamic_rule_name like concat('%', #{dynamicRuleName}, '%')
|
||||
</if>
|
||||
<if test="dynamicRuleId != null">
|
||||
and t_dynamic_rule.dynamic_rule_id = #{dynamicRuleId}
|
||||
</if>
|
||||
<if test="sourceSystem != null">
|
||||
<if test="sourceSystem != null and sourceSystem !=''">
|
||||
and t_strategy_template.strategy_template_source_system = #{sourceSystem}
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
<if test="creator != null and creator !=''">
|
||||
and t_dynamic_rule.dynamic_rule_create_username = #{creator}
|
||||
</if>
|
||||
<if test="auditStatus != null">
|
||||
and t_dynamic_rule.audit_status = #{auditStatus}
|
||||
</if>
|
||||
</where>
|
||||
LIMIT ${(page - 1) * pageSize}, #{pageSize}
|
||||
</select>
|
||||
@@ -244,6 +247,9 @@
|
||||
<if test="creator != null">
|
||||
and t_dynamic_rule.dynamic_rule_create_username = #{creator}
|
||||
</if>
|
||||
<if test="auditStatus != null">
|
||||
and t_dynamic_rule.audit_status = #{auditStatus}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="queryDynamicRuleByIds"
|
||||
|
||||
@@ -156,6 +156,9 @@
|
||||
AND (static_rule_sip = INET_ATON(#{ip}) or static_rule_msip = INET_ATON(#{ip})
|
||||
or static_rule_dip = INET_ATON(#{ip}) or static_rule_mdip = INET_ATON(#{ip}))
|
||||
</if>
|
||||
<if test="auditStatus != null">
|
||||
AND static_rule_audit_status = #{auditStatus}
|
||||
</if>
|
||||
</where>
|
||||
LIMIT ${(page - 1) * pageSize}, #{pageSize}
|
||||
</select>
|
||||
@@ -188,6 +191,9 @@
|
||||
AND (static_rule_sip = INET_ATON(#{ip}) or static_rule_msip = INET_ATON(#{ip})
|
||||
or static_rule_dip = INET_ATON(#{ip}) or static_rule_mdip = INET_ATON(#{ip}))
|
||||
</if>
|
||||
<if test="auditStatus != null">
|
||||
AND static_rule_audit_status = #{auditStatus}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="queryStaticRuleByIds"
|
||||
|
||||
@@ -129,13 +129,13 @@ public class DynamicRuleServiceTest extends ProtectionApplicationTests {
|
||||
@Test
|
||||
void testQueryDynamicRuleObject() {
|
||||
List<DynamicRuleObject> objects = dynamicRuleService.queryDynamicRuleObject(
|
||||
null,null,null, null,1, 10);
|
||||
null,null,null, null,2,1, 10);
|
||||
System.out.println(objects);
|
||||
}
|
||||
@Test
|
||||
void testQueryDynamicRuleTotalNum(){
|
||||
Integer num = dynamicRuleService.queryDynamicRuleTotalNum(
|
||||
null,null,null,null);
|
||||
null,null,null,null,null);
|
||||
System.out.println(num);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public class StaticRuleServiceTest extends ProtectionApplicationTests {
|
||||
|
||||
@Test
|
||||
void testQueryStaticRules(){
|
||||
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(null, null, null, null, 1, 10);
|
||||
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(null, null, null, null,2, 1, 10);
|
||||
System.out.println(staticRuleObjects);
|
||||
}
|
||||
@Test
|
||||
|
||||
@@ -73,14 +73,14 @@ class TaskServiceTest extends ProtectionApplicationTests {
|
||||
void testNewTaskSuccess() {
|
||||
for (int i = 1; i < 10; i++) {
|
||||
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(
|
||||
null, null, null, null, i, 2);
|
||||
null, null, null, null,2, i, 2);
|
||||
List<Integer> staticRuleIds = new ArrayList<>();
|
||||
staticRuleObjects.forEach(staticRuleObject ->
|
||||
staticRuleIds.add(staticRuleObject.getStaticRuleId()));
|
||||
task.setStaticRuleIds(staticRuleIds);
|
||||
|
||||
List<DynamicRuleObject> dynamicRuleObjects = dynamicRuleService.queryDynamicRuleObject(
|
||||
null, null, null, null, i, 2
|
||||
null, null, null, null,null, i, 2
|
||||
);
|
||||
List<Integer> dynamicRuleIds = new ArrayList<>();
|
||||
dynamicRuleObjects.forEach(dynamicRuleObject ->
|
||||
@@ -104,6 +104,13 @@ class TaskServiceTest extends ProtectionApplicationTests {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testPageQueryTask(){
|
||||
List<Task> tasks = taskService.queryTasks(null, null, null, null, null, 1, 10);
|
||||
System.out.println(tasks);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testQueryTasks() {
|
||||
String testName = "test query";
|
||||
@@ -113,14 +120,14 @@ class TaskServiceTest extends ProtectionApplicationTests {
|
||||
task.setTaskName(testName);
|
||||
task.setTaskCreateUsername(testCreateName);
|
||||
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(
|
||||
null, null, null, null, 1, 5);
|
||||
null, null, null, null, null,1, 5);
|
||||
List<Integer> staticRuleIds = new ArrayList<>();
|
||||
staticRuleObjects.forEach(staticRuleObject ->
|
||||
staticRuleIds.add(staticRuleObject.getStaticRuleId()));
|
||||
task.setStaticRuleIds(staticRuleIds);
|
||||
|
||||
List<DynamicRuleObject> dynamicRuleObjects = dynamicRuleService.queryDynamicRuleObject(
|
||||
null, null, null, null, 1, 5
|
||||
null, null, null, null, null,1, 5
|
||||
);
|
||||
List<Integer> dynamicRuleIds = new ArrayList<>();
|
||||
dynamicRuleObjects.forEach(dynamicRuleObject ->
|
||||
@@ -157,7 +164,7 @@ class TaskServiceTest extends ProtectionApplicationTests {
|
||||
.get(0);
|
||||
|
||||
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(
|
||||
null, null, null, null, 1, 4
|
||||
null, null, null, null, null,1, 4
|
||||
);
|
||||
List<Integer> staticRuleIds = new ArrayList<>();
|
||||
staticRuleObjects.forEach(staticRuleObject -> staticRuleIds.add(staticRuleObject.getStaticRuleId()));
|
||||
|
||||
@@ -114,7 +114,7 @@ class WhiteListServiceTest extends ProtectionApplicationTests {
|
||||
|
||||
Integer id = staticRuleService.newStaticRuleObject(staticRuleTest);
|
||||
List<Integer> ruleIds = new ArrayList<>(List.of(id));
|
||||
List<StaticRuleObject> staticRules= staticRuleService.queryStaticRule(null,null,null,null,1,2);
|
||||
List<StaticRuleObject> staticRules= staticRuleService.queryStaticRule(null,null,null,null,null,1,2);
|
||||
for (StaticRuleObject staticRule : staticRules) {
|
||||
ruleIds.add(staticRule.getStaticRuleId());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user