1、DynamicRule的新增、更新添加对id、protectObjectId的判断;分页查询添加creator、sourceSystem查询条件;按id查询新增template_id为null的判断
2、StaticRule新增usedTaskStatus字段,多查单查返回usedTaskStatus;增、改、查、改审核状态添加id无效判断; 分页新增creator、ip查询条件 3、whiteList修改审核status,添加id无效判断
This commit is contained in:
@@ -36,7 +36,9 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
log.info("新增静态规则: {}", object);
|
||||
//调用service新增
|
||||
staticRuleService.newStaticRuleObject(object);
|
||||
return ResponseResult.ok().setData("static_rule_name", object.getStaticRuleName());
|
||||
return ResponseResult.ok()
|
||||
.setData("static_rule_id", object.getStaticRuleId())
|
||||
.setData("static_rule_name", object.getStaticRuleName());
|
||||
}
|
||||
|
||||
//以Excel方式批量导入静态规则
|
||||
@@ -96,7 +98,10 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
@RequestBody @Valid StaticRuleObject object) {
|
||||
log.info("修改静态规则: {}", object);
|
||||
//调用service修改
|
||||
staticRuleService.updateStaticRule(id, object);
|
||||
Integer updateValid = staticRuleService.updateStaticRule(id, object);
|
||||
if (updateValid == 0) {
|
||||
return ResponseResult.invalid().setMessage("id is invalid");
|
||||
}
|
||||
return ResponseResult.ok();
|
||||
}
|
||||
|
||||
@@ -109,6 +114,9 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
public ResponseResult queryStaticRuleById(@PathVariable Integer id) {
|
||||
log.info("根据id查询静态规则:{}", id);
|
||||
StaticRuleObject object = staticRuleService.queryStaticRuleById(id);
|
||||
if (object == null) {
|
||||
return ResponseResult.invalid().setMessage("id is invalid");
|
||||
}
|
||||
return ResponseResult.ok().setData("static_rule", object);
|
||||
}
|
||||
|
||||
@@ -117,13 +125,18 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
||||
*/
|
||||
@Override
|
||||
@GetMapping("/query")
|
||||
public ResponseResult queryStaticRule(String static_rule_name, Integer static_rule_id,
|
||||
public ResponseResult queryStaticRule(@RequestParam(name = "name", required = false) String static_rule_name,
|
||||
@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(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize
|
||||
) {
|
||||
log.info("多查询静态规则: {},{},{},{}", static_rule_name, static_rule_id, page, pageSize);
|
||||
//调用service新增
|
||||
List<StaticRuleObject> pageResult = staticRuleService.queryStaticRule(static_rule_name, static_rule_id, page, pageSize);
|
||||
List<StaticRuleObject> pageResult = staticRuleService.queryStaticRule(
|
||||
static_rule_name, static_rule_id,
|
||||
static_rule_creator, static_rule_ip, page, pageSize);
|
||||
return ResponseResult.ok().setData("static_rule_list", pageResult);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,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.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -137,15 +138,21 @@ public interface StaticRuleControllerApi {
|
||||
)
|
||||
},
|
||||
parameters = {
|
||||
@Parameter(name = "static_rule_name", description = "静态规则名称"),
|
||||
@Parameter(name = "static_rule_id", description = "静态规则id"),
|
||||
@Parameter(name = "name", description = "静态规则名称"),
|
||||
@Parameter(name = "id", description = "静态规则id"),
|
||||
@Parameter(name = "creator", description = "静态规则创建人"),
|
||||
@Parameter(name = "ip", description = "静态规则ip,匹配所有源和目的ip"),
|
||||
@Parameter(name = "page", description = "页码"),
|
||||
@Parameter(name = "pageSize", description = "每页条数")
|
||||
}
|
||||
)
|
||||
ResponseResult queryStaticRule(String static_rule_name, Integer static_rule_id,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize);
|
||||
ResponseResult queryStaticRule(@RequestParam(required = false) String static_rule_name,
|
||||
@RequestParam(required = false) Integer static_rule_id,
|
||||
@RequestParam(required = false) String static_rule_creator,
|
||||
@RequestParam(required = false) String static_rule_ip,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer pageSize
|
||||
);
|
||||
|
||||
|
||||
@Operation(
|
||||
@@ -166,6 +173,8 @@ public interface StaticRuleControllerApi {
|
||||
)
|
||||
ResponseResult deleteStaticRule(@PathVariable Integer id) ;
|
||||
|
||||
|
||||
|
||||
@Operation(
|
||||
summary = "更新静态规则审批状态",
|
||||
description = "更新静态规则审批状态,0未审核、1审核不通过、2审核通过",
|
||||
|
||||
@@ -19,7 +19,7 @@ public interface StaticRuleMapper {
|
||||
|
||||
|
||||
//修改静态规则
|
||||
void updateStaticRule(@Param("id") Integer id, @Param("object") StaticRuleObject object);
|
||||
Integer updateStaticRule(@Param("id") Integer id, @Param("object") StaticRuleObject object);
|
||||
|
||||
//按id查询静态规则
|
||||
//@Select("select * from t_static_rule where static_rule_id = #{id}")
|
||||
@@ -27,6 +27,7 @@ public interface StaticRuleMapper {
|
||||
|
||||
//多页查询静态规则
|
||||
List<StaticRuleObject> queryStaticRule(String static_rule_name, Integer static_rule_id,
|
||||
String static_rule_create_username, String ip,
|
||||
Integer page, Integer pageSize);
|
||||
|
||||
|
||||
|
||||
@@ -73,12 +73,12 @@ public class StaticRuleService {
|
||||
return sqlSessionWrapper.startBatchSession(StaticRuleMapper.class, deleteStaticRulesFunction, staticRuleIds);
|
||||
}
|
||||
|
||||
public void updateStaticRule(Integer id, StaticRuleObject object) {
|
||||
public Integer updateStaticRule(Integer id, StaticRuleObject object) {
|
||||
//判断当前静态规则是否能够修改---是否存在任务选择的静态规则??
|
||||
//按id查询该静态规则的used_task_id字段,如果不为空,则不能修改
|
||||
object.setStaticRuleModifyTime(LocalDateTime.now());
|
||||
//修改静态规则
|
||||
staticRuleMapper.updateStaticRule(id, object);
|
||||
return staticRuleMapper.updateStaticRule(id, object);
|
||||
}
|
||||
|
||||
public StaticRuleObject queryStaticRuleById(Integer id) {
|
||||
@@ -89,9 +89,13 @@ public class StaticRuleService {
|
||||
/*
|
||||
分页查询
|
||||
*/
|
||||
public List<StaticRuleObject> queryStaticRule(String static_rule_name, Integer static_rule_id, Integer page, Integer pageSize) {
|
||||
public List<StaticRuleObject> queryStaticRule(
|
||||
String static_rule_name, Integer static_rule_id,
|
||||
String creator, String ip,
|
||||
Integer page, Integer pageSize) {
|
||||
|
||||
return staticRuleMapper.queryStaticRule(static_rule_name, static_rule_id, page, pageSize);
|
||||
return staticRuleMapper.queryStaticRule(static_rule_name, static_rule_id,
|
||||
creator, ip, page, pageSize);
|
||||
}
|
||||
|
||||
public Boolean newStaticRuleObjects(List<StaticRuleObject> staticRuleList) {
|
||||
@@ -126,6 +130,9 @@ public class StaticRuleService {
|
||||
@Transactional
|
||||
public Map<String, Object> updateAuditStatus(Integer id, Integer auditStatus) {
|
||||
Integer originalAuditStatus = staticRuleMapper.queryAuditStatusById(id);
|
||||
if (originalAuditStatus == null) {
|
||||
throw new IllegalArgumentException("cannot find audit status of static rule " + id + ", maybe static rule doesn't exist?");
|
||||
}
|
||||
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
|
||||
throw new IllegalArgumentException("invalid audit status");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user