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