增加删除所有配置规则功能.
This commit is contained in:
@@ -230,6 +230,24 @@ public class ServiceConfigTemplateUtil {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static Set<String> getAllTableName(){
|
||||
//Set<String> tableName = getCompileTableName();
|
||||
Set<String> result = Sets.newHashSet();
|
||||
List<Map<String, Object>> serviceList = getServiceList();
|
||||
for (Map<String, Object> serviceNode : serviceList) {
|
||||
result.add(serviceNode.get("tableName").toString().trim());
|
||||
List<Map<String,Object>> cfgList = (List<Map<String, Object>>) serviceNode.get("cfgList");
|
||||
if(cfgList != null) {
|
||||
for (Map<String, Object> map : cfgList) {
|
||||
result.add(map.get("tableName").toString().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
ServiceConfigTemplateUtil serviceTemplate = new ServiceConfigTemplateUtil();
|
||||
|
||||
@@ -198,4 +198,18 @@ public class SystemController extends BaseController{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@RequestMapping("clearPolicies")
|
||||
@ResponseBody
|
||||
public boolean clearPolicies(HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
systemService.clearPolicies();
|
||||
/*ArrayList<Object> list = Lists.newArrayList();
|
||||
System.out.println(list.get(6));*/
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
logger.error("Clear Policies Error",e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ package com.nis.web.dao;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.nis.domain.SysOffice;
|
||||
|
||||
@MyBatisDao
|
||||
@@ -27,6 +29,8 @@ public interface SysOfficeDao extends TreeDao<SysOffice> {
|
||||
List<SysOffice> selectOfficeForDeptment(Map map);
|
||||
|
||||
List<SysOffice> selectOfficeForLetter(Map<String, Object> hmap);
|
||||
|
||||
void clearPolicies(@Param("tableName")String tableName);
|
||||
|
||||
|
||||
}
|
||||
@@ -327,5 +327,10 @@
|
||||
<if test="dbName == 'mysql'">CONCAT('%,', #{id}, ',%')</if>
|
||||
</update>
|
||||
|
||||
<update id="clearPolicies" parameterType="java.lang.String">
|
||||
UPDATE ${tableName}
|
||||
SET is_valid = -1, is_audit = 0
|
||||
WHERE is_valid != -1
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -30,5 +30,6 @@ public interface AsnGroupInfoDao extends CrudDao<AsnGroupInfo> {
|
||||
Long getCount();
|
||||
void modifyIssuedIp(AsnGroupInfo info);
|
||||
void updateIpNum(@Param("v4Num")long v4Num,@Param("v6Num")long v6Num,@Param("groupId")Integer groupId);
|
||||
List<Object[]> getASNIPNum(@Param("asnNo")Integer asnNo);
|
||||
List<Object[]> getASNIPNum(@Param("asnNo")Integer asnNo);
|
||||
void reLoadGroupInfo();
|
||||
}
|
||||
@@ -290,5 +290,18 @@
|
||||
</update>
|
||||
<select id="getASNIPNum" resultType="map">
|
||||
select v4_num,v6_num from asn_group_info where asn_id=#{asnNo}
|
||||
</select>
|
||||
</select>
|
||||
|
||||
<update id="reLoadGroupInfo">
|
||||
UPDATE asn_group_info SET
|
||||
issued_ips = 0,
|
||||
is_used = 0,
|
||||
org_group_id = null,
|
||||
region_id = 0,
|
||||
v4_num = 0,
|
||||
v6_num = 0,
|
||||
only_group_id = null
|
||||
WHERE is_valid != -1
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -23,4 +23,5 @@ public interface ConfigGroupInfoDao extends CrudDao<ConfigGroupInfo>{
|
||||
//获取asn组织的groupId
|
||||
ConfigGroupInfo getAsnGroupByName(@Param("groupName")String groupName);
|
||||
int delAsnGroup(@Param("groupName")String groupName);
|
||||
void reLoadGroupInfo();
|
||||
}
|
||||
|
||||
@@ -90,4 +90,8 @@
|
||||
<delete id="delAsnGroup" parameterType="java.lang.String">
|
||||
delete from config_group_info where group_name=#{groupName} and group_type=4
|
||||
</delete>
|
||||
|
||||
<delete id="reLoadGroupInfo">
|
||||
DELETE FROM config_group_info WHERE group_type = 1
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -10,6 +10,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
@@ -39,6 +40,7 @@ import com.nis.domain.SysUser;
|
||||
import com.nis.util.Configurations;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.IpUtil;
|
||||
import com.nis.util.ServiceConfigTemplateUtil;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.TimeConstants;
|
||||
import com.nis.web.dao.SrcIpDao;
|
||||
@@ -48,6 +50,7 @@ import com.nis.web.security.CacheSessionDAO;
|
||||
import com.nis.web.security.Servlets;
|
||||
import com.nis.web.security.SessionDAO;
|
||||
import com.nis.web.security.UserUtils;
|
||||
import com.nis.web.service.basics.AsnGroupInfoService;
|
||||
|
||||
import antlr.StringUtils;
|
||||
|
||||
@@ -64,6 +67,9 @@ public class SystemService extends BaseService{
|
||||
@Autowired
|
||||
private SysOfficeDao sysOfficeDao;
|
||||
|
||||
@Autowired
|
||||
private AsnGroupInfoService asnGroupInfoService;
|
||||
|
||||
@Autowired
|
||||
private SrcIpDao srcIpDao;
|
||||
private RedisSerializer keySerializer = new StringSerializer();
|
||||
@@ -179,4 +185,18 @@ public class SystemService extends BaseService{
|
||||
method.addChild(secE);
|
||||
return method;
|
||||
}
|
||||
|
||||
public void clearPolicies() throws Exception {
|
||||
// TODO 调用服务接口 告知flushAll
|
||||
/*String destUrl = Constants.SERVICE_URL;
|
||||
HttpClientUtil.get(destUrl);*/
|
||||
Set<String> tableNameSet = ServiceConfigTemplateUtil.getAllTableName();
|
||||
tableNameSet.add("pxy_obj_spoofing_ip_pool");
|
||||
for (String tableName : tableNameSet) {
|
||||
sysOfficeDao.clearPolicies(tableName);
|
||||
}
|
||||
// 初始化分组
|
||||
asnGroupInfoService.reLoadGroupInfo();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,4 +238,13 @@ public class AsnGroupInfoService extends BaseService{
|
||||
List<AsnGroupInfo> list=asnGroupInfoDao.findAsnGroupInfoList(entity);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear Policies操作初始化分组状态
|
||||
*/
|
||||
public void reLoadGroupInfo() {
|
||||
asnGroupInfoDao.reLoadGroupInfo();
|
||||
configGroupInfoDao.reLoadGroupInfo();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -265,6 +265,29 @@ function initSpoofingIp(){
|
||||
}
|
||||
})
|
||||
}
|
||||
function clearPolicies(){
|
||||
top.$.jBox.confirm("<spring:message code='confirm_message'/>","Clear Policies",function(v,h,f){
|
||||
if(v=="ok"){
|
||||
$.ajax({
|
||||
type:'get',
|
||||
url:'${ctx}/sys/clearPolicies',
|
||||
dataType:'json',
|
||||
async:false,
|
||||
success:function(data,textStatus){
|
||||
if(data){
|
||||
top.$.jBox.info('Policies Cleaning Successful!', 'Waring', {closed:function(v,h,f){
|
||||
window.location.href = "${ctx}/index";
|
||||
}});
|
||||
top.$('.jbox-body .jbox-icon').css('top','55px');
|
||||
}else{
|
||||
alertx("Policies Cleanup Failure!");
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
top.$('.jbox-body .jbox-icon').css('top','55px');
|
||||
}
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.bodyhi{
|
||||
@@ -391,6 +414,15 @@ background:#3d3d3d;
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown dropdown-user nav" style="display: none">
|
||||
<a href="javascript:clearPolicies()" id="helpHref" target="_self" >
|
||||
<i class="fa fa-remove"></i>
|
||||
<span class="username username-hide-on-mobile" id="help">
|
||||
Clear Policies
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</c:if>
|
||||
<li class="dropdown dropdown-user nav">
|
||||
<a href="${pageContext.request.contextPath}/static/PotPlayerSetup64.exe" id="helpHref" target="_self" >
|
||||
|
||||
Reference in New Issue
Block a user