1、静态规则增加重复性检测
This commit is contained in:
@@ -52,6 +52,10 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
|||||||
object.setStaticRuleCreateUserId(Integer.valueOf(user.uid));
|
object.setStaticRuleCreateUserId(Integer.valueOf(user.uid));
|
||||||
object.setStaticRuleCreateDepart(user.getOrgName());
|
object.setStaticRuleCreateDepart(user.getOrgName());
|
||||||
}
|
}
|
||||||
|
Integer duplicateRuleNum = staticRuleService.queryDuplicateStaticRule(object);
|
||||||
|
if (duplicateRuleNum > 0) {
|
||||||
|
return ResponseResult.invalid().setMessage("规则重复");
|
||||||
|
}
|
||||||
|
|
||||||
//调用service新增
|
//调用service新增
|
||||||
staticRuleService.newStaticRuleObject(object);
|
staticRuleService.newStaticRuleObject(object);
|
||||||
@@ -126,7 +130,7 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
|||||||
//调用service修改
|
//调用service修改
|
||||||
Boolean updateValid = staticRuleService.updateStaticRule(id, object);
|
Boolean updateValid = staticRuleService.updateStaticRule(id, object);
|
||||||
if (!updateValid) {
|
if (!updateValid) {
|
||||||
return ResponseResult.invalid().setMessage("id is invalid");
|
return ResponseResult.invalid().setMessage("无效的规则");
|
||||||
}
|
}
|
||||||
return ResponseResult.ok().setData("success",updateValid);
|
return ResponseResult.ok().setData("success",updateValid);
|
||||||
}
|
}
|
||||||
@@ -141,7 +145,7 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
|||||||
log.info("根据id查询静态规则:{}", id);
|
log.info("根据id查询静态规则:{}", id);
|
||||||
StaticRuleObject object = staticRuleService.queryStaticRuleById(id);
|
StaticRuleObject object = staticRuleService.queryStaticRuleById(id);
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
return ResponseResult.invalid().setMessage("id is invalid");
|
return ResponseResult.invalid().setMessage("无效的规则");
|
||||||
}
|
}
|
||||||
return ResponseResult.ok().setData("static_rule", object);
|
return ResponseResult.ok().setData("static_rule", object);
|
||||||
}
|
}
|
||||||
@@ -199,7 +203,7 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
|||||||
public ResponseResult updateStaticRuleAuditStatus(@PathVariable Integer id, @PathVariable Integer auditStatus,
|
public ResponseResult updateStaticRuleAuditStatus(@PathVariable Integer id, @PathVariable Integer auditStatus,
|
||||||
@Autowired HttpServletRequest request) {
|
@Autowired HttpServletRequest request) {
|
||||||
if (id <= 0 || auditStatus < 0 || auditStatus > 2) {
|
if (id <= 0 || auditStatus < 0 || auditStatus > 2) {
|
||||||
return new ResponseResult(400, "id or status is invalid")
|
return new ResponseResult(400, "规则或状态无效")
|
||||||
.setData("staticRule_id", id)
|
.setData("staticRule_id", id)
|
||||||
.setData("success", false);
|
.setData("success", false);
|
||||||
}
|
}
|
||||||
@@ -238,7 +242,7 @@ public class StaticRuleController implements StaticRuleControllerApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!errorIds.isEmpty()){
|
if (!errorIds.isEmpty()){
|
||||||
return new ResponseResult(400, "id or status is invalid")
|
return new ResponseResult(400, "规则或状态无效")
|
||||||
.setData("staticRule_id", errorIds)
|
.setData("staticRule_id", errorIds)
|
||||||
.setData("success", false);
|
.setData("success", false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,5 +81,7 @@ public interface StaticRuleMapper {
|
|||||||
|
|
||||||
void removeUsedTaskId(Long taskId);
|
void removeUsedTaskId(Long taskId);
|
||||||
|
|
||||||
|
Integer queryDuplicateStaticRule(StaticRuleObject object);
|
||||||
|
|
||||||
// boolean queryStaticRuleRepeat(StaticRuleObject object);
|
// boolean queryStaticRuleRepeat(StaticRuleObject object);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -428,4 +428,8 @@ public class StaticRuleService {
|
|||||||
public List<StaticRuleObject> queryHistory(Integer id, Integer page, Integer pageSize) {
|
public List<StaticRuleObject> queryHistory(Integer id, Integer page, Integer pageSize) {
|
||||||
return staticRuleMapper.queryHistory(id, page, pageSize);
|
return staticRuleMapper.queryHistory(id, page, pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer queryDuplicateStaticRule(StaticRuleObject object) {
|
||||||
|
return staticRuleMapper.queryDuplicateStaticRule(object);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -518,35 +518,50 @@
|
|||||||
ORDER BY effective_time DESC
|
ORDER BY effective_time DESC
|
||||||
LIMIT ${(page - 1) * pageSize}, #{pageSize}
|
LIMIT ${(page - 1) * pageSize}, #{pageSize}
|
||||||
</select>
|
</select>
|
||||||
<!-- <select id="queryStaticRuleRepeat" resultType="java.lang.Boolean">-->
|
<select id="queryDuplicateStaticRule" resultType="java.lang.Integer">
|
||||||
<!-- SELECT COUNT(*)-->
|
|
||||||
<!-- FROM t_static_rule-->
|
SELECT COUNT(*)
|
||||||
<!-- WHERE-->
|
FROM t_static_rule
|
||||||
<!-- <if test="sip != null and sip != ''">-->
|
WHERE
|
||||||
<!-- static_rule_sip = INET_ATON(#{sip})-->
|
<if test="staticRuleSip != null and staticRuleSip != ''">
|
||||||
<!-- </if>-->
|
static_rule_sip = INET_ATON(#{staticRuleSip})
|
||||||
<!-- <if test="dip != null and dip != ''">-->
|
</if>
|
||||||
<!-- AND static_rule_dip = INET_ATON(#{dip})-->
|
<if test="staticRuleDip != null and staticRuleDip != ''">
|
||||||
<!-- </if>-->
|
AND static_rule_dip = INET_ATON(#{staticRuleDip})
|
||||||
<!-- <if test="sport != null">-->
|
</if>
|
||||||
<!-- AND static_rule_sport = #{sport}-->
|
<if test="staticRuleSport != null and staticRuleSport != ''">
|
||||||
<!-- </if>-->
|
AND static_rule_sport = #{staticRuleSport}
|
||||||
<!-- <if test="dport != null">-->
|
</if>
|
||||||
<!-- AND static_rule_dport = #{dport}-->
|
<if test="staticRuleDport != null and staticRuleDport != ''">
|
||||||
<!-- </if>-->
|
AND static_rule_dport = #{staticRuleDport}
|
||||||
<!-- <if test="protocol != null">-->
|
</if>
|
||||||
<!-- AND static_rule_protocol = #{protocol}-->
|
<if test="staticRuleProtocol != null and staticRuleProtocol != ''">
|
||||||
<!-- </if>-->
|
AND static_rule_protocol = #{staticRuleProtocol}
|
||||||
<!-- <if test="dns != null and dns != ''">-->
|
</if>
|
||||||
<!-- AND static_rule_dns = #{dns}-->
|
<if test="staticRuleDns != null and staticRuleDns != ''">
|
||||||
<!-- </if>-->
|
AND static_rule_dns = #{staticRuleDns}
|
||||||
<!-- <if test="url != null and url != ''">-->
|
</if>
|
||||||
<!-- AND static_rule_url = #{url} -->
|
<if test="staticRuleURL != null and staticRuleURL != ''">
|
||||||
<!-- </if>-->
|
AND static_rule_url = #{staticRuleURL}
|
||||||
<!-- <if test="eventType != null">-->
|
</if>
|
||||||
<!-- AND event_type = #{eventType}-->
|
<if test="staticRuleMsip != null and staticRuleMsip != ''">
|
||||||
<!-- </if>-->
|
AND static_rule_msip = INET_ATON(#{staticRuleMsip})
|
||||||
<!-- -->
|
</if>
|
||||||
<!-- </select>-->
|
<if test="staticRuleMdip != null and staticRuleMdip != ''">
|
||||||
|
AND static_rule_mdip = INET_ATON(#{staticRuleMdip})
|
||||||
|
</if>
|
||||||
|
<if test="staticRuleMsport != null and staticRuleMsport != '' ">
|
||||||
|
AND static_rule_msport = #{staticRuleMsport}
|
||||||
|
</if>
|
||||||
|
<if test="staticRuleMdport != null and staticRuleMdport != ''">
|
||||||
|
AND static_rule_mdport = #{staticRuleMdport}
|
||||||
|
</if>
|
||||||
|
<if test="staticRuleMprotocol != null and staticRuleMprotocol != ''">
|
||||||
|
AND static_rule_mprotocol = #{staticRuleMprotocol}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user