1、动态规则:新增批量审核、统计接口。修改query动态规则不查询auditstatus
2、静态规则:新增批量审核、统计接口。 3、任务:新增批量审核、统计接口。 4、白名单:新增统计接口、 5、防护对象:新增统计接口 6、策略模板:新增统计接口
This commit is contained in:
@@ -4,6 +4,8 @@ import com.realtime.protection.configuration.entity.task.Task;
|
||||
import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
|
||||
import com.realtime.protection.configuration.exception.DorisStartException;
|
||||
import com.realtime.protection.configuration.response.ResponseResult;
|
||||
import com.realtime.protection.configuration.utils.enums.StateEnum;
|
||||
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
|
||||
import com.realtime.protection.server.command.CommandService;
|
||||
import com.realtime.protection.server.task.status.StateChangeService;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -162,6 +164,7 @@ public class TaskController implements TaskControllerApi {
|
||||
/**
|
||||
* 批量修改审核状态
|
||||
*/
|
||||
@Override
|
||||
@PostMapping("/auditbatch")
|
||||
public ResponseResult updateTaskAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap) {
|
||||
List<Integer> errorIds = new ArrayList<>();
|
||||
@@ -172,7 +175,7 @@ public class TaskController implements TaskControllerApi {
|
||||
errorIds.add(id);
|
||||
}
|
||||
}
|
||||
if (!errorIds.isEmpty()){
|
||||
if (!errorIds.isEmpty()) {
|
||||
return new ResponseResult(400, "id or status is invalid")
|
||||
.setData("tasks_id", errorIds)
|
||||
.setData("success", false);
|
||||
@@ -181,4 +184,20 @@ public class TaskController implements TaskControllerApi {
|
||||
return ResponseResult.ok()
|
||||
.setData("success", taskService.updateAuditStatusBatch(idsWithAuditStatusMap));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/statistics")
|
||||
public ResponseResult statistics() {
|
||||
return ResponseResult.ok()
|
||||
.setData("total_num", taskService.queryTaskTotalNum(null, null, null, null))
|
||||
.setData("running_num", taskService.queryTaskTotalNum(StateEnum.RUNNING.getStateNum(), null, null, null))
|
||||
.setData("finished_num", taskService.queryTaskTotalNum(StateEnum.FINISHED.getStateNum(), null, null, null))
|
||||
.setData("unaudit_num", taskService.queryAuditTaskTotalNum(
|
||||
AuditStatusEnum.PENDING.getNum()
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,6 +17,8 @@ import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Tag(name = "任务控制器API", description = "任务管理模块相关的所有接口")
|
||||
public interface TaskControllerApi {
|
||||
@PostMapping("/new")
|
||||
@@ -521,4 +523,71 @@ public interface TaskControllerApi {
|
||||
@GetMapping("/{commandId}/valid/{isJudged}")
|
||||
ResponseResult setCommandJudged(@PathVariable Boolean isJudged,
|
||||
@PathVariable String commandId);
|
||||
|
||||
@Operation(
|
||||
summary = "批量更新任务审批状态",
|
||||
description = "批量更新任务审批状态,0未审核、1审核不通过、2审核通过",
|
||||
responses = {
|
||||
@io.swagger.v3.oas.annotations.responses.ApiResponse(
|
||||
description = "返回任务审核结果",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class)
|
||||
)
|
||||
)
|
||||
},
|
||||
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||
description = "字典,key是任务id,value是任务审核状态id",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = Map.class)
|
||||
|
||||
)
|
||||
)
|
||||
)
|
||||
@PostMapping("/auditbatch")
|
||||
ResponseResult updateTaskAuditStatusBatch(@RequestBody Map<Integer, Integer> idsWithAuditStatusMap);
|
||||
|
||||
@Operation(
|
||||
summary = "数据统计",
|
||||
description = "数据统计",
|
||||
responses = {
|
||||
@ApiResponse(
|
||||
description = "返回数据统计",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class),
|
||||
examples = @ExampleObject(
|
||||
name = "example",
|
||||
value = """
|
||||
{
|
||||
"code": 200,
|
||||
"message": "request succeed",
|
||||
"data": {
|
||||
"total_num": 11,
|
||||
"running_num": 2,
|
||||
"finished_num": 5,
|
||||
"unaudit_num": 5
|
||||
}
|
||||
}
|
||||
""",
|
||||
description = """
|
||||
"total_num": 总数
|
||||
|
||||
"running_num": 运行任务数
|
||||
|
||||
"finished_num": 结束任务数
|
||||
|
||||
"unaudit_num": 未审核数
|
||||
"""
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
parameters = {
|
||||
|
||||
}
|
||||
)
|
||||
@GetMapping("/statistics")
|
||||
ResponseResult statistics();
|
||||
}
|
||||
|
||||
@@ -61,4 +61,6 @@ public interface TaskMapper {
|
||||
@Param("task_name") String taskName, @Param("task_creator") String taskCreator);
|
||||
|
||||
void updateAuditStatusByIdBatch(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idWithAuditStatusBatch);
|
||||
|
||||
Integer queryAuditTaskTotalNum(Integer auditState);
|
||||
}
|
||||
|
||||
@@ -334,4 +334,8 @@ public class TaskService {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Integer queryAuditTaskTotalNum(Integer auditState) {
|
||||
return taskMapper.queryAuditTaskTotalNum(auditState);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user