1、动态、静态规则、任务、白名单、防护对象、策略模板的查询总数增加了条件
2、指令分页查询还有bug
This commit is contained in:
@@ -32,4 +32,10 @@ public interface CommandMapper {
|
||||
TaskCommandInfo queryCommandInfoByUUID(@Param("uuid") String uuid);
|
||||
|
||||
String queryCommandInfo(@Param("command_info") TaskCommandInfo commandInfo);
|
||||
|
||||
Integer queryCommandTotalNum(@Param("task_id") Long taskId,
|
||||
@Param("src_ip") String sourceIP,
|
||||
@Param("src_port") String sourcePort,
|
||||
@Param("dst_ip") String destinationIP,
|
||||
@Param("dst_port") String destinationPort);
|
||||
}
|
||||
|
||||
@@ -93,4 +93,9 @@ public class CommandService {
|
||||
public Boolean setCommandJudged(String commandId, Boolean isValid) {
|
||||
return commandMapper.setCommandJudged(commandId, isValid);
|
||||
}
|
||||
|
||||
public Integer queryCommandTotalNum(Long taskId, String sourceIP, String sourcePort,
|
||||
String destinationIP, String destinationPort){
|
||||
return commandMapper.queryCommandTotalNum(taskId, sourceIP, sourcePort, destinationIP, destinationPort);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ProtectObjectController implements ProtectObjectControllerApi {
|
||||
return ResponseResult.ok()
|
||||
.setData("proobj_list", protectObjectService.queryProtectObjects(protectObjectName,
|
||||
protectObjectId, page, pageSize))
|
||||
.setData("total_num", protectObjectService.queryProtectObjectsTotalNum());
|
||||
.setData("total_num", protectObjectService.queryProtectObjectsTotalNum(protectObjectName, protectObjectId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.realtime.protection.server.defense.object;
|
||||
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,6 +28,7 @@ public interface ProtectObjectMapper {
|
||||
Boolean changeProtectObjectAuditStatus(@Param("proobj_id") Integer protectObjectId,
|
||||
@Param("proobj_audit_status") Integer protectObjectAuditStatus);
|
||||
|
||||
@Select("SELECT COUNT(protect_object_id) FROM t_protect_object")
|
||||
Integer queryProtectObjectsTotalNum();
|
||||
|
||||
Integer queryProtectObjectsTotalNum(@Param("proobj_name") String protectObjectName,
|
||||
@Param("proobj_id") Integer protectObjectId);
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class ProtectObjectService {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
public Integer queryProtectObjectsTotalNum() {
|
||||
return protectObjectMapper.queryProtectObjectsTotalNum();
|
||||
public Integer queryProtectObjectsTotalNum(String protectObjectName, Integer protectObjectId) {
|
||||
return protectObjectMapper.queryProtectObjectsTotalNum(protectObjectName, protectObjectId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class TemplateController implements TemplateControllerApi {
|
||||
|
||||
return ResponseResult.ok()
|
||||
.setData("templates", templates)
|
||||
.setData("total_num", templateService.queryTemplateTotalNum());
|
||||
.setData("total_num", templateService.queryTemplateTotalNum(templateName));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.realtime.protection.configuration.entity.defense.template.Template;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -28,6 +27,5 @@ public interface TemplateMapper {
|
||||
@Delete("DELETE FROM t_strategy_template WHERE strategy_template_id = #{template_id}")
|
||||
Boolean deleteTemplate(@Param("template_id") Integer templateId);
|
||||
|
||||
@Select("SELECT COUNT(strategy_template_id) FROM t_strategy_template")
|
||||
Integer queryTemplateTotalNum();
|
||||
Integer queryTemplateTotalNum(String templateName);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class TemplateService {
|
||||
return templateMapper.deleteTemplate(templateId);
|
||||
}
|
||||
|
||||
public Integer queryTemplateTotalNum() {
|
||||
return templateMapper.queryTemplateTotalNum();
|
||||
public Integer queryTemplateTotalNum(String templateName) {
|
||||
return templateMapper.queryTemplateTotalNum(templateName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,8 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
|
||||
.setData("success", true)
|
||||
.setData("dynamic_rule_list", dynamicRuleService.queryDynamicRuleObject(dynamicRuleName, dynamicRuleId,
|
||||
protectObjectSourceSystem, creator, page, pageSize))
|
||||
.setData("total_num",dynamicRuleService.queryDynamicRuleTotalNum());
|
||||
.setData("total_num",dynamicRuleService.queryDynamicRuleTotalNum(dynamicRuleName, dynamicRuleId,
|
||||
protectObjectSourceSystem, creator));
|
||||
}
|
||||
|
||||
//详情查看?? 就是按id查询吧
|
||||
|
||||
@@ -41,5 +41,6 @@ public interface DynamicRuleMapper {
|
||||
|
||||
boolean queryProtectObjectById(Integer protectObjectId);
|
||||
|
||||
Integer queryDynamicRuleTotalNum();
|
||||
Integer queryDynamicRuleTotalNum(String dynamicRuleName, Integer dynamicRuleId,
|
||||
String sourceSystem, String creator);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,9 @@ public class DynamicRuleService {
|
||||
templateSourceSystem, creator, page, pageSize);
|
||||
}
|
||||
|
||||
public Integer queryDynamicRuleTotalNum() {
|
||||
return dynamicRuleMapper.queryDynamicRuleTotalNum();
|
||||
public Integer queryDynamicRuleTotalNum(String dynamicRuleName, Integer dynamicRuleId,
|
||||
String protectObjectSourceSystem, String creator) {
|
||||
return dynamicRuleMapper.queryDynamicRuleTotalNum(dynamicRuleName, dynamicRuleId,
|
||||
protectObjectSourceSystem, creator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,8 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
static_rule_creator, static_rule_ip, page, pageSize);
|
||||
return ResponseResult.ok()
|
||||
.setData("static_rule_list", pageResult)
|
||||
.setData("total_num",staticRuleService.queryStaticRuleTotalNum());
|
||||
.setData("total_num",staticRuleService.queryStaticRuleTotalNum(static_rule_name, static_rule_id,
|
||||
static_rule_creator, static_rule_ip));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,5 +39,6 @@ public interface StaticRuleMapper {
|
||||
|
||||
Boolean updateAuditStatusById(Integer id, Integer auditStatus);
|
||||
|
||||
Integer queryStaticRuleTotalNum();
|
||||
Integer queryStaticRuleTotalNum(String static_rule_name, Integer static_rule_id,
|
||||
String static_rule_create_username, String ip);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,9 @@ public class StaticRuleService {
|
||||
staticRuleMapper.deleteStaticRuleById(id);
|
||||
}
|
||||
|
||||
public Integer queryStaticRuleTotalNum() {
|
||||
return staticRuleMapper.queryStaticRuleTotalNum();
|
||||
public Integer queryStaticRuleTotalNum(String static_rule_name, Integer static_rule_id,
|
||||
String static_rule_creator, String static_rule_ip) {
|
||||
return staticRuleMapper.queryStaticRuleTotalNum(static_rule_name, static_rule_id,
|
||||
static_rule_creator, static_rule_ip);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class TaskController implements TaskControllerApi {
|
||||
@Override
|
||||
@GetMapping("/query")
|
||||
public ResponseResult queryTasks(@RequestParam(value = "task_status", required = false) Integer taskStatus,
|
||||
@RequestParam(value = "task_type", required = false) String taskType,
|
||||
@RequestParam(value = "task_type", required = false) Integer taskType,
|
||||
@RequestParam(value = "task_name", required = false) String taskName,
|
||||
@RequestParam(value = "task_creator", required = false) String taskCreator,
|
||||
@RequestParam("page") @Min(1) Integer page,
|
||||
@@ -75,7 +75,7 @@ public class TaskController implements TaskControllerApi {
|
||||
List<Task> tasks = taskService.queryTasks(taskStatus, taskType, taskName, taskCreator, page, pageSize);
|
||||
return ResponseResult.ok()
|
||||
.setData("task_list", tasks)
|
||||
.setData("total_num", taskService.queryTaskTotalNum());
|
||||
.setData("total_num", taskService.queryTaskTotalNum(taskStatus, taskType, taskName, taskCreator));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -143,7 +143,8 @@ public class TaskController implements TaskControllerApi {
|
||||
|
||||
return ResponseResult.ok()
|
||||
.setData("success", true)
|
||||
.setData("commands", taskCommandInfos);
|
||||
.setData("commands", taskCommandInfos)
|
||||
.setData("total_num", commandService.queryCommandTotalNum(taskId, sourceIP, sourcePort, destinationIP, destinationPort));
|
||||
}
|
||||
|
||||
@GetMapping("/{commandId}/valid/{isJudged}")
|
||||
|
||||
@@ -186,7 +186,7 @@ public interface TaskControllerApi {
|
||||
}
|
||||
)
|
||||
ResponseResult queryTasks(@RequestParam(value = "task_status", required = false) Integer taskStatus,
|
||||
@RequestParam(value = "task_type", required = false) String taskType,
|
||||
@RequestParam(value = "task_type", required = false) Integer taskType,
|
||||
@RequestParam(value = "task_name", required = false) String taskName,
|
||||
@RequestParam(value = "task_creator", required = false) String taskCreator,
|
||||
@RequestParam("page") @Min(1) Integer page,
|
||||
|
||||
@@ -21,7 +21,7 @@ public interface TaskMapper {
|
||||
|
||||
void newTaskUsingCommandInfo(@Param("info") TaskCommandInfo taskCommandInfo);
|
||||
|
||||
List<Task> queryTasks(@Param("task_status") Integer taskStatus, @Param("task_type") String task_type,
|
||||
List<Task> queryTasks(@Param("task_status") Integer taskStatus, @Param("task_type") Integer task_type,
|
||||
@Param("task_name") String taskName, @Param("task_creator") String taskCreator,
|
||||
@Param("page") Integer page, @Param("page_size") Integer pageSize);
|
||||
|
||||
@@ -54,6 +54,7 @@ public interface TaskMapper {
|
||||
@Select("SELECT task_id FROM t_task WHERE task_end_time < NOW() AND task_status != #{task_status}")
|
||||
List<Long> queryTasksByStatus(@Param("task_status") Integer taskStatus);
|
||||
|
||||
@Select("SELECT COUNT(task_id) FROM t_task")
|
||||
Integer queryTaskTotalNum();
|
||||
|
||||
Integer queryTaskTotalNum(@Param("task_status") Integer taskStatus, @Param("task_type") Integer task_type,
|
||||
@Param("task_name") String taskName, @Param("task_creator") String taskCreator);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TaskService {
|
||||
|
||||
@Transactional
|
||||
public List<Task> queryTasks(Integer taskStatus,
|
||||
String taskType, String taskName, String taskCreator,
|
||||
Integer taskType, String taskName, String taskCreator,
|
||||
Integer page, Integer pageSize) {
|
||||
List<Task> tasks = taskMapper.queryTasks(taskStatus, taskType, taskName, taskCreator, page, pageSize);
|
||||
for (Task task : tasks) {
|
||||
@@ -132,7 +132,7 @@ public class TaskService {
|
||||
return taskMapper.queryTasksByStatus(StateEnum.FINISHED.getStateNum());
|
||||
}
|
||||
|
||||
public Integer queryTaskTotalNum() {
|
||||
return taskMapper.queryTaskTotalNum();
|
||||
public Integer queryTaskTotalNum(Integer taskStatus, Integer taskType, String taskName,String taskCreator) {
|
||||
return taskMapper.queryTaskTotalNum(taskStatus, taskType, taskName, taskCreator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class WhiteListController implements WhiteListControllerApi {
|
||||
}
|
||||
return ResponseResult.ok()
|
||||
.setData("whiteobj_list", whiteListService.queryWhiteListObject(whiteListName, whiteListId, page, pageSize))
|
||||
.setData("total_num", whiteListService.queryWhiteListTotalNum());
|
||||
.setData("total_num", whiteListService.queryWhiteListTotalNum(whiteListName, whiteListId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,5 +39,5 @@ public interface WhiteListMapper {
|
||||
|
||||
List<WhiteListObject> whiteListCommandJudge(@Param("command") FiveTupleWithMask fiveTupleWithMaskInCommand);
|
||||
|
||||
Integer queryWhiteListTotalNum();
|
||||
Integer queryWhiteListTotalNum(String whiteListName, Integer whiteListId);
|
||||
}
|
||||
|
||||
@@ -157,8 +157,8 @@ public class WhiteListService {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
public Integer queryWhiteListTotalNum(){
|
||||
return whiteListMapper.queryWhiteListTotalNum();
|
||||
public Integer queryWhiteListTotalNum(String whiteListName, Integer whiteListId){
|
||||
return whiteListMapper.queryWhiteListTotalNum(whiteListName, whiteListId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -170,4 +170,41 @@
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="queryCommandTotalNum" resultType="java.lang.Integer">
|
||||
SELECT COUNT(COMMAND_ID)
|
||||
FROM t_command
|
||||
<where>
|
||||
<if test="command_info.taskId != null">AND TASK_ID = #{command_info.taskId}</if>
|
||||
<if test="command_info.fiveTupleWithMask.sourceIP != null">
|
||||
AND SRC_IP = #{command_info.fiveTupleWithMask.sourceIP}
|
||||
</if>
|
||||
<if test="command_info.fiveTupleWithMask.destinationIP != null">
|
||||
AND DST_IP = #{command_info.fiveTupleWithMask.destinationIP}
|
||||
</if>
|
||||
<if test="command_info.fiveTupleWithMask.sourcePort != null">
|
||||
AND SRC_PORT = #{command_info.fiveTupleWithMask.sourcePort}
|
||||
</if>
|
||||
<if test="command_info.fiveTupleWithMask.destinationPort != null">
|
||||
AND DST_PORT = #{command_info.fiveTupleWithMask.destinationPort}
|
||||
</if>
|
||||
<if test="command_info.fiveTupleWithMask.protocol != null">
|
||||
AND PROTOCOL = #{command_info.fiveTupleWithMask.protocol}
|
||||
</if>
|
||||
<if test="command_info.fiveTupleWithMask.maskSourceIP != null">
|
||||
AND MASK_SRC_IP = #{command_info.fiveTupleWithMask.maskSourceIP}
|
||||
</if>
|
||||
<if test="command_info.fiveTupleWithMask.maskSourcePort != null">
|
||||
AND MASK_SOURCE_PORT = #{command_info.fiveTupleWithMask.maskSourcePort}
|
||||
</if>
|
||||
<if test="command_info.fiveTupleWithMask.maskDestinationIP != null">
|
||||
AND MASK_DST_IP = #{command_info.fiveTupleWithMask.maskDestinationIP}
|
||||
</if>
|
||||
<if test="command_info.fiveTupleWithMask.maskDestinationPort != null">
|
||||
AND MASK_DST_PORT = #{command_info.fiveTupleWithMask.maskDestinationPort}
|
||||
</if>
|
||||
<if test="command_info.fiveTupleWithMask.maskProtocol != null">
|
||||
AND MASK_PROTOCOL = #{command_info.fiveTupleWithMask.maskProtocol}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -209,6 +209,20 @@
|
||||
<select id="queryDynamicRuleTotalNum" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM t_dynamic_rule
|
||||
<where>
|
||||
<if test="dynamicRuleName != null">
|
||||
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">
|
||||
and t_strategy_template.strategy_template_source_system = #{sourceSystem}
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
and t_dynamic_rule.dynamic_rule_create_username = #{creator}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
@@ -69,6 +69,13 @@
|
||||
FROM t_protect_object
|
||||
WHERE protect_object_id = #{proobj_id}
|
||||
</select>
|
||||
<select id="queryProtectObjectsTotalNum" resultType="java.lang.Integer">
|
||||
SELECT COUNT(protect_object_id) FROM t_protect_object
|
||||
<where>
|
||||
<if test="proobj_name != null">protect_object_name LIKE CONCAT('%', #{proobj_name}, '%')</if>
|
||||
<if test="proobj_id != null">protect_object_id = #{proobj_id}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="updateProtectObject">
|
||||
UPDATE t_protect_object
|
||||
|
||||
@@ -161,6 +161,21 @@
|
||||
<select id="queryStaticRuleTotalNum" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM t_static_rule
|
||||
<where>
|
||||
<if test="static_rule_name != null and static_rule_name != ''">
|
||||
static_rule_name like concat('%', #{static_rule_name}, '%')
|
||||
</if>
|
||||
<if test="static_rule_id != null">
|
||||
AND static_rule_id = #{static_rule_id}
|
||||
</if>
|
||||
<if test="static_rule_create_username != null and static_rule_create_username != ''">
|
||||
AND static_rule_create_username like concat('%', #{static_rule_create_username}, '%')
|
||||
</if>
|
||||
<if test="ip != null and ip != ''">
|
||||
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>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -259,4 +259,22 @@
|
||||
INNER JOIN realtime_protection.t_strategy_template tst on tdr.template_id = tst.strategy_template_id
|
||||
WHERE task_id = #{task_id}
|
||||
</select>
|
||||
<select id="queryTaskTotalNum" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM t_task
|
||||
<where>
|
||||
<if test="task_status != null">
|
||||
AND task_status = #{task_status}
|
||||
</if>
|
||||
<if test="task_type != null">
|
||||
AND task_type = #{task_type}
|
||||
</if>
|
||||
<if test="task_name != null">
|
||||
AND task_name LIKE CONCAT('%', #{task_name}, '%')
|
||||
</if>
|
||||
<if test="task_creator != null">
|
||||
AND task_create_username LIKE CONCAT('%', #{task_creator}, '%')
|
||||
</if>
|
||||
</where>
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -105,6 +105,14 @@
|
||||
FROM t_protect_level
|
||||
WHERE protect_level_id = #{level_id}
|
||||
</select>
|
||||
<select id="queryTemplateTotalNum" resultType="java.lang.Integer">
|
||||
SELECT COUNT(strategy_template_id) FROM t_strategy_template
|
||||
<where>
|
||||
<if test="template_name != null">
|
||||
AND strategy_template_name LIKE CONCAT('%', #{template_name}, '%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="updateTemplateInformation">
|
||||
UPDATE t_strategy_template
|
||||
|
||||
@@ -201,6 +201,14 @@
|
||||
<select id="queryWhiteListTotalNum" resultType="java.lang.Integer">
|
||||
select COUNT(*)
|
||||
from t_white_list
|
||||
<where>
|
||||
<if test="whiteListName != null">
|
||||
white_list_name like concat('%', #{whiteListName}, '%')
|
||||
</if>
|
||||
<if test="whiteListId != null">
|
||||
and white_list_id = #{whiteListId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user