1. application.yml修改为application-dev.yml和application-prod.yml
2. 添加更多Exception拦截器 3. 编写状态模式处理task状态的更改 4. 添加StateChangeService,用以处理所有任务状态转换相关的内容 5. 添加StateEnum, ProtocolEnum,TaskTypeEnum用以处理任务和协议相关的所有状态和类型
This commit is contained in:
@@ -3,6 +3,7 @@ package com.realtime.protection.server.defense.object;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
|
||||
import com.realtime.protection.configuration.response.ResponseResult;
|
||||
import com.realtime.protection.configuration.utils.EntityUtils;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.Min;
|
||||
@@ -76,21 +77,15 @@ public class ProtectObjectController {
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/query")
|
||||
public ResponseResult queryProtectObject(@PathVariable("id") Integer protectObjectId) {
|
||||
@GetMapping("/{protectObjectId}/query")
|
||||
public ResponseResult queryProtectObject(@PathVariable Integer protectObjectId) throws IllegalAccessException {
|
||||
ProtectObject protectObject = protectObjectService.queryProtectObject(protectObjectId);
|
||||
return ResponseResult.ok()
|
||||
.setData("proobj_id", protectObject.getProtectObjectId())
|
||||
.setData("proobj_name", protectObject.getProtectObjectName())
|
||||
.setData("proobj_system_name", protectObject.getProtectObjectSystemName())
|
||||
.setData("proobj_ip_address", protectObject.getProtectObjectIPAddress())
|
||||
.setData("proobj_port", protectObject.getProtectObjectPort())
|
||||
.setData("proobj_url", protectObject.getProtectObjectURL())
|
||||
.setData("proobj_protocol", protectObject.getProtectObjectProtocol());
|
||||
.setDataMap(EntityUtils.entityToMap(protectObject));
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/update")
|
||||
public ResponseResult updateProtectObject(@PathVariable("id") Integer protectObjectId,
|
||||
@PostMapping("/{protectObjectId}/update")
|
||||
public ResponseResult updateProtectObject(@PathVariable Integer protectObjectId,
|
||||
@RequestBody @Valid ProtectObject protectObject) {
|
||||
protectObject.setProtectObjectId(protectObjectId);
|
||||
return ResponseResult.ok()
|
||||
@@ -98,8 +93,8 @@ public class ProtectObjectController {
|
||||
.setData("success", protectObjectService.updateProtectObject(protectObject));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}/delete")
|
||||
public ResponseResult deleteProtectObject(@PathVariable("id") Integer protectObjectId) {
|
||||
@DeleteMapping("/{protectObjectId}/delete")
|
||||
public ResponseResult deleteProtectObject(@PathVariable Integer protectObjectId) {
|
||||
return ResponseResult.ok()
|
||||
.setData("proobj_id", protectObjectId)
|
||||
.setData("success", protectObjectService.deleteProtectObject(protectObjectId));
|
||||
@@ -112,9 +107,9 @@ public class ProtectObjectController {
|
||||
.setData("success", protectObjectService.deleteProtectObjects(protectObjectIds));
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/audit/{status}")
|
||||
public ResponseResult changeProtectObjectAuditStatus(@PathVariable("id") Integer protectObjectId,
|
||||
@PathVariable("status") Integer auditStatus) {
|
||||
@PostMapping("/{protectObjectId}/audit/{auditStatus}")
|
||||
public ResponseResult changeProtectObjectAuditStatus(@PathVariable Integer protectObjectId,
|
||||
@PathVariable Integer auditStatus) {
|
||||
return ResponseResult.ok()
|
||||
.setDataMap(protectObjectService.changeProtectObjectAuditStatus(protectObjectId, auditStatus))
|
||||
.setData("proobj_id", protectObjectId);
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.realtime.protection.server.defense.object;
|
||||
|
||||
import com.alibaba.excel.util.ListUtils;
|
||||
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
|
||||
import com.realtime.protection.configuration.utils.status.AuditStatusValidator;
|
||||
import com.realtime.protection.configuration.utils.SqlSessionWrapper;
|
||||
import com.realtime.protection.configuration.utils.status.AuditStatusValidator;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ProtectObjectService {
|
||||
protectObjectBatch.clear();
|
||||
}
|
||||
if (!protectObjectBatch.isEmpty()) {
|
||||
mapper.deleteProtectObjects(protectObjectBatch);;
|
||||
mapper.deleteProtectObjects(protectObjectBatch);
|
||||
}
|
||||
return success;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.realtime.protection.server.defense.template;
|
||||
|
||||
import com.realtime.protection.configuration.entity.defense.template.Template;
|
||||
import com.realtime.protection.configuration.response.ResponseResult;
|
||||
import com.realtime.protection.configuration.utils.EntityUtils;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -43,16 +44,22 @@ public class TemplateController {
|
||||
|
||||
@GetMapping("/query")
|
||||
public ResponseResult queryTemplates(@RequestParam(value = "template_name", required = false) String templateName,
|
||||
@RequestParam("page") @Min(1) Integer page,
|
||||
@RequestParam("page_size") @Min(1) Integer pageSize) {
|
||||
@RequestParam("page") @Min(1) Integer page,
|
||||
@RequestParam("page_size") @Min(1) Integer pageSize) {
|
||||
List<Template> templates = templateService.queryTemplates(templateName, page, pageSize);
|
||||
|
||||
return ResponseResult.ok()
|
||||
.setData("templates", templates);
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/update")
|
||||
public ResponseResult updateTemplate(@PathVariable("id") @Min(1) Integer templateId,
|
||||
@GetMapping("/{templateId}/query")
|
||||
public ResponseResult queryTemplate(@PathVariable Integer templateId) throws IllegalAccessException {
|
||||
return ResponseResult.ok()
|
||||
.setDataMap(EntityUtils.entityToMap(templateService.queryTemplate(templateId)));
|
||||
}
|
||||
|
||||
@PostMapping("/{templateId}/update")
|
||||
public ResponseResult updateTemplate(@PathVariable @Min(1) Integer templateId,
|
||||
@RequestBody @Valid Template template) {
|
||||
Boolean success = templateService.updateTemplate(templateId, template);
|
||||
return ResponseResult.ok()
|
||||
@@ -60,14 +67,10 @@ public class TemplateController {
|
||||
.setData("success", success);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/addUsedTimes")
|
||||
public ResponseResult addTemplateUsedTimes(@PathVariable("id") @Min(1) Integer templateId,
|
||||
@RequestParam(value = "add_num") @Min(0) Integer addNum) {
|
||||
Boolean success = templateService.addTemplateUsedTimes(templateId, addNum);
|
||||
@DeleteMapping("/{templateId}/delete")
|
||||
public ResponseResult deleteTemplate(@PathVariable @Min(1) Integer templateId) {
|
||||
return ResponseResult.ok()
|
||||
.setData("template_id", templateId)
|
||||
.setData("success", success);
|
||||
.setData("success", templateService.deleteTemplate(templateId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public interface TemplateMapper {
|
||||
|
||||
Boolean updateTemplateInformation(@Param("template") Template template);
|
||||
|
||||
void countTemplateRunningTasks(@Param("template_id") Integer templateId);
|
||||
Template queryTemplate(@Param("template_id") Integer templateId);
|
||||
|
||||
Boolean addTemplateUsedTimes(@Param("template_id") Integer templateId, @Param("add_times") Integer addTimes);
|
||||
Boolean deleteTemplate(@Param("template_id") Integer templateId);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ import com.realtime.protection.configuration.entity.defense.template.Template;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.beans.Transient;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@@ -41,8 +39,11 @@ public class TemplateService {
|
||||
return templateMapper.updateTemplateInformation(template);
|
||||
}
|
||||
|
||||
public Boolean addTemplateUsedTimes(Integer templateId, Integer addTimes) {
|
||||
return templateMapper.addTemplateUsedTimes(templateId, addTimes);
|
||||
public Template queryTemplate(Integer templateId) {
|
||||
return templateMapper.queryTemplate(templateId);
|
||||
}
|
||||
|
||||
public Boolean deleteTemplate(Integer templateId) {
|
||||
return templateMapper.deleteTemplate(templateId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user