完善IP复用地址池、策略配置.

This commit is contained in:
zhangwq
2018-12-01 16:06:08 +08:00
parent 68e822bb26
commit 8cfb175fd2
18 changed files with 804 additions and 405 deletions

View File

@@ -18,21 +18,22 @@ public interface IpAddrPoolCfgDao extends CrudDao<IpAddrPoolCfgDao>{
,@Param("isAudit")Integer isAudit
,@Param("isValid")Integer isValid);
void saveAddrPoolCfg(IpAddrPoolCfg cfg);
void updateAddrPoolCfg(IpAddrPoolCfg entity);
void saveReuseIpCfgs(BaseIpCfg ipCfg);
List<BaseIpCfg> getReuseIpCfgs(@Param("addrPoolId")Integer addrPoolId);
void deleteReuseIpCfgs(@Param("addrPoolId")Integer addrPoolId);
Integer getAddrPoolId(@Param("cfgId")Long cfgId);
List<BaseIpCfg> getReuseIpCfgs(@Param("cfgId")Long cfgId);
IpAddrPoolCfg getCfgInfo(IpAddrPoolCfg cfg);
void saveAddrPoolCfg(IpAddrPoolCfg cfg);
void saveReuseIpCfgs(BaseIpCfg ipCfg);
void updateAddrPoolCfg(IpAddrPoolCfg entity);
void updateReuseIpCfgs(IpAddrPoolCfg entity);
void deleteReuseIpCfgs(@Param("addrPoolId")Long addrPoolId);
List<IpAddrPoolCfg> findAddrPoolCfg();
Long getAddrPoolIdByName(String addrPoolName);
}

View File

@@ -3,11 +3,9 @@
<mapper namespace="com.nis.web.dao.configuration.IpAddrPoolCfgDao">
<resultMap id="addrPoolMap" type="com.nis.domain.configuration.IpAddrPoolCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="addr_pool_id" property="addrPoolId" jdbcType="INTEGER"/>
<id column="cfg_id" property="cfgId" jdbcType="BIGINT"/>
<result column="addr_pool_name" property="addrPoolName" jdbcType="VARCHAR"/>
<result column="ip_total" property="ipTotal" jdbcType="INTEGER"/>
<result column="available_ip_total" property="availableIpTotal" jdbcType="INTEGER"/>
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
@@ -38,7 +36,7 @@
</resultMap>
<sql id="addrPoolColumns">
r.CFG_ID,r.ADDR_POOL_ID,r.IP_TOTAL,r.AVAILABLE_IP_TOTAL,r.ACTION,r.IS_VALID,r.IS_AUDIT,
r.CFG_ID,r.ADDR_POOL_NAME,r.IP_TOTAL,r.ACTION,r.IS_VALID,r.IS_AUDIT,
r.CFG_REGION_CODE,r.CFG_TYPE,r.FUNCTION_ID,r.SERVICE_ID,r.COMPILE_ID,r.REQUEST_ID,
r.CLASSIFY,r.ATTRIBUTE,r.LABLE,
r.CREATOR_ID,r.CREATE_TIME,r.EDITOR_ID,r.EDIT_TIME,r.AUDITOR_ID,r.AUDIT_TIME,
@@ -62,13 +60,10 @@
,s.name as creator_name,
e.name as editor_name,
u.name as auditor_name,
a.group_name as addr_pool_name,
ri.request_title as requestName
</trim>
FROM
ip_reuse_addr_pool r
left join
policy_group_info a on r.addr_pool_id = a.group_Id
left join
sys_user s on r.creator_id = s.id
left join
@@ -81,24 +76,18 @@
<if test="page !=null and page.where != null and page.where != ''">
AND ${page.where}
</if>
<if test="cfgId != null">
AND r.CFG_ID=#{cfgId,jdbcType=BIGINT}
<if test="cfgId != null">
AND r.cfg_id=#{cfgId,jdbcType=BIGINT}
</if>
<if test="compileId != null">
AND r.compile_id=#{compileId,jdbcType=BIGINT}
</if>
<if test="addrPoolId != null">
AND r.addr_pool_id = #{addrPoolId,jdbcType=INTEGER}
</if>
<if test="addrPoolName != null and addrPoolName != ''">
AND r.addr_pool_name = #{addrPoolName,jdbcType=VARCHAR}
AND r.addr_pool_name LIKE concat(concat('%',#{addrPoolName,jdbcType=VARCHAR}),'%')
</if>
<if test="ipTotal != null">
AND r.ip_total = #{ipTotal,jdbcType=INTEGER}
</if>
<if test="availableIpTotal != null">
AND r.available_ip_total = #{availableIpTotal,jdbcType=INTEGER}
</if>
<if test="action != null">
AND r.ACTION=#{action,jdbcType=INTEGER}
</if>
@@ -149,7 +138,7 @@
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY r.CFG_ID DESC
ORDER BY r.cfg_id DESC
</otherwise>
</choose>
</select>
@@ -161,6 +150,9 @@
FROM
ip_reuse_addr_pool r
<where>
<if test="cfgId != null">
AND r.cfg_id=#{cfgId,jdbcType=BIGINT}
</if>
<if test="isValid !=null">
AND r.is_valid = #{isValid,jdbcType=INTEGER}
</if>
@@ -169,12 +161,9 @@
</if>
<if test="isAudit !=null">
AND r.is_audit = #{isAudit,jdbcType=INTEGER}
</if>
<if test="cfgId != null">
AND r.cfg_id = #{cfgId,jdbcType=BIGINT}
</if>
</where>
ORDER BY cfg_Id
</if>
</where>
ORDER BY r.cfg_id
</select>
<!-- 保存地址池IP信息 -->
@@ -258,10 +247,8 @@
<insert id="saveAddrPoolCfg" parameterType="com.nis.domain.configuration.IpAddrPoolCfg">
INSERT INTO ip_reuse_addr_pool(
addr_pool_id,
addr_pool_name,
ip_total,
available_ip_total,
action,
is_valid,
is_audit,
@@ -289,10 +276,8 @@
user_region4,
user_region5
)VALUES (
#{addrPoolId,jdbcType=INTEGER},
#{addrPoolName,jdbcType=VARCHAR},
#{ipTotal,jdbcType=INTEGER},
#{availableIpTotal,jdbcType=INTEGER},
#{action,jdbcType=INTEGER},
0,
0,
@@ -328,19 +313,62 @@
FROM
ip_reuse_ip_cfg a
WHERE
a.is_valid != -1 AND a.user_region1 = #{addrPoolId}
a.is_valid != -1 AND a.user_region1 = #{cfgId}
</select>
<select id="getAddrPoolId" resultType="java.lang.Integer">
SELECT
a.addr_pool_id
FROM
ip_reuse_addr_pool a
WHERE
a.is_valid != -1 AND a.cfg_id = #{cfgId}
</select>
<update id="updateReuseIpCfgs" parameterType="com.nis.domain.configuration.IpAddrPoolCfg">
update ip_reuse_ip_cfg
<set >
<trim suffixOverrides=",">
<if test="isValid != null" >
is_valid = #{isValid,jdbcType=INTEGER},
</if>
<if test="isAudit != null" >
is_audit = #{isAudit,jdbcType=INTEGER},
</if>
<if test="creatorId != null" >
creator_id = #{creatorId,jdbcType=INTEGER},
</if>
<if test="createTime != null and createTime != ''" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="editorId != null" >
editor_id = #{editorId,jdbcType=INTEGER},
</if>
<if test="editTime != null and editTime != ''" >
edit_time = #{editTime,jdbcType=TIMESTAMP},
</if>
<if test="auditorId != null" >
auditor_id = #{auditorId,jdbcType=INTEGER},
</if>
<if test="auditTime != null and createTime != ''" >
audit_time = #{auditTime,jdbcType=TIMESTAMP},
</if>
<if test="requestId != null" >
request_id = #{requestId,jdbcType=INTEGER},
</if>
<if test="isAreaEffective != null" >
is_area_effective = #{isAreaEffective,jdbcType=INTEGER},
</if>
<if test="classify != null and classify != ''" >
classify = #{classify,jdbcType=VARCHAR},
</if>
<if test="attribute != null and attribute != ''" >
attribute = #{attribute,jdbcType=VARCHAR},
</if>
<if test="lable != null and lable != ''" >
lable = #{lable,jdbcType=VARCHAR},
</if>
<if test="areaEffectiveIds != null" >
area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR},
</if>
</trim>
</set>
where user_region1 = #{cfgId,jdbcType=BIGINT}
</update>
<delete id="deleteReuseIpCfgs" parameterType="java.lang.Integer">
<delete id="deleteReuseIpCfgs" parameterType="java.lang.Long">
DELETE FROM ip_reuse_ip_cfg WHERE user_region1 = #{addrPoolId}
</delete>
@@ -348,18 +376,9 @@
update ip_reuse_addr_pool
<set >
<trim suffixOverrides=",">
<if test="addrPoolId != null" >
addr_pool_id = #{addrPoolId,jdbcType=INTEGER},
</if>
<if test="ipTotal != null" >
ip_total = #{ipTotal,jdbcType=INTEGER},
</if>
<if test="availableIpTotal != null" >
available_ip_total = #{availableIpTotal,jdbcType=INTEGER},
</if>
<if test="action != null" >
action = #{action,jdbcType=INTEGER},
</if>
<if test="isValid != null" >
is_valid = #{isValid,jdbcType=INTEGER},
</if>
@@ -423,16 +442,16 @@
FROM ip_reuse_addr_pool r
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="cfgId != null">
AND r.cfg_id=#{cfgId,jdbcType=BIGINT}
AND r.cfg_id = #{cfgId,jdbcType=BIGINT}
</if>
<if test="isValid !=null">
AND r.is_valid =#{isValid,jdbcType=INTEGER}
AND r.is_valid = #{isValid,jdbcType=INTEGER}
</if>
<if test="isValid == null">
AND r.is_valid != -1
</if>
<if test="functionId != null">
AND r.function_id=#{functionId,jdbcType=INTEGER}
AND r.function_id = #{functionId,jdbcType=INTEGER}
</if>
<if test="addrPoolName != null and addrPoolName != ''">
AND r.addr_pool_name = #{addrPoolName,jdbcType=VARCHAR}
@@ -442,7 +461,16 @@
<select id="findAddrPoolCfg" resultMap="addrPoolMap">
SELECT
<include refid="addrPoolColumns"/>,r.ADDR_POOL_NAME
<include refid="addrPoolColumns"/>
FROM ip_reuse_addr_pool r WHERE r.is_audit=1
</select>
<select id="getAddrPoolIdByName" resultType="java.lang.Long">
SELECT
r.cfg_id
FROM
ip_reuse_addr_pool r
WHERE
r.addr_pool_name = #{addrPoolName} AND r.is_valid != -1
</select>
</mapper>

View File

@@ -0,0 +1,26 @@
package com.nis.web.dao.configuration;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.nis.domain.configuration.IpReusePolicyCfg;
import com.nis.web.dao.CrudDao;
import com.nis.web.dao.MyBatisDao;
@MyBatisDao
public interface IpMultiplexDao extends CrudDao<IpMultiplexDao>{
List<IpReusePolicyCfg> findPage(IpReusePolicyCfg entity);
List<IpReusePolicyCfg> findList(@Param("cfgId")Long cfgId
,@Param("isAudit")Integer isAudit
,@Param("isValid")Integer isValid);
void savePolicyCfg(IpReusePolicyCfg entity);
void updatePolicyCfg(IpReusePolicyCfg entity);
String getUserType(@Param("userId")Integer userId);
}

View File

@@ -0,0 +1,311 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.nis.web.dao.configuration.IpMultiplexDao">
<resultMap id="policyMap" type="com.nis.domain.configuration.IpReusePolicyCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT"/>
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR"/>
<result column="addr_pool_id" property="addrPoolId" jdbcType="INTEGER"/>
<result column="user_id" property="userId" jdbcType="INTEGER"/>
<result column="user_type" property="userType" jdbcType="VARCHAR"/>
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="user_region1" property="userRegion1" jdbcType="VARCHAR" />
<result column="user_region2" property="userRegion2" jdbcType="VARCHAR" />
<result column="user_region3" property="userRegion3" jdbcType="VARCHAR" />
<result column="user_region4" property="userRegion4" jdbcType="VARCHAR" />
<result column="user_region5" property="userRegion5" jdbcType="VARCHAR" />
<result column="cancel_request_id" property="cancelRequestId" jdbcType="INTEGER" />
</resultMap>
<sql id="policyColumns">
r.CFG_ID,r.CFG_DESC,r.ADDR_POOL_ID,r.USER_ID,r.USER_TYPE,
r.ACTION,r.IS_VALID,r.IS_AUDIT,r.CFG_REGION_CODE,r.CFG_TYPE,r.FUNCTION_ID,
r.SERVICE_ID,r.COMPILE_ID,r.REQUEST_ID,r.CLASSIFY,r.ATTRIBUTE,r.LABLE,
r.CREATOR_ID,r.CREATE_TIME,r.EDITOR_ID,r.EDIT_TIME,r.AUDITOR_ID,r.AUDIT_TIME,
r.CANCEL_REQUEST_ID,r.IS_AREA_EFFECTIVE,r.AREA_EFFECTIVE_IDS,
r.USER_REGION1,r.USER_REGION2,r.USER_REGION3,r.USER_REGION4,r.USER_REGION5
</sql>
<select id="findPage" resultMap="policyMap">
SELECT
<include refid="policyColumns"/>
<trim prefix="," prefixOverrides=",">
,s.name as creator_name,
e.name as editor_name,
u.name as auditor_name,
ri.request_title as requestName
</trim>
FROM
ip_reuse_policy_cfg r
left join
sys_user s on r.creator_id = s.id
left join
sys_user e on r.editor_id = e.id
left join
sys_user u on r.auditor_id = u.id
left join
request_info ri on r.request_id = ri.id
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="page !=null and page.where != null and page.where != ''">
AND ${page.where}
</if>
<if test="cfgId != null">
AND r.cfg_id=#{cfgId,jdbcType=BIGINT}
</if>
<if test="compileId != null">
AND r.compile_id=#{compileId,jdbcType=BIGINT}
</if>
<if test="userName != null and userName != ''">
AND r.user_id in (SELECT u.id FROM user_manage u
<where>
u.user_name LIKE concat(concat('%',#{userName,jdbcType=VARCHAR}),'%')
</where>
)
</if>
<if test="addrPoolName != null and addrPoolName != ''">
AND r.addr_pool_id in (SELECT i.cfg_id FROM ip_reuse_addr_pool i
<where>
i.addr_pool_name LIKE concat(concat('%',#{addrPoolName,jdbcType=VARCHAR}),'%')
</where>
)
</if>
<if test="compileId != null">
AND r.compile_id=#{compileId,jdbcType=BIGINT}
</if>
<if test="action != null">
AND r.ACTION=#{action,jdbcType=INTEGER}
</if>
<if test="isValid != null">
AND r.IS_VALID=#{isValid,jdbcType=INTEGER}
</if>
<if test="isValid == null">
AND r.IS_VALID != -1
</if>
<if test="isAudit != null">
AND r.IS_AUDIT=#{isAudit,jdbcType=INTEGER}
</if>
<if test="creatorName != null and creatorName != ''">
AND CREATOR_NAME like concat(concat('%',#{creatorName,jdbcType=VARCHAR}),'%')
</if>
<if test="editorName != null and editorName != ''">
AND r.EDITOR_NAME like concat(concat('%',#{editorName,jdbcType=VARCHAR}),'%')
</if>
<if test="auditorName != null and auditorName != ''">
AND AUDITOR_NAME like concat(concat('%',#{auditorName,jdbcType=VARCHAR}),'%')
</if>
<if test="serviceId != null">
AND r.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
</if>
<if test="requestId != null">
AND r.REQUEST_ID=#{requestId,jdbcType=INTEGER}
</if>
<if test="isAreaEffective != null">
AND r.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER}
</if>
<if test="classify != null and classify != ''">
AND r.classify like concat(concat('%',#{classify,jdbcType=VARCHAR}),'%')
</if>
<if test="attribute != null and attribute != ''">
AND r.attribute like concat(concat('%',#{attribute,jdbcType=VARCHAR}),'%')
</if>
<if test="lable != null and lable != ''">
AND r.lable like concat(concat('%',#{lable,jdbcType=VARCHAR}),'%')
</if>
<if test="functionId != null">
AND r.function_id=#{functionId,jdbcType=INTEGER}
</if>
<!-- 数据范围过滤 -->
${sqlMap.dsf}
</trim>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY r.cfg_id DESC
</otherwise>
</choose>
</select>
<!-- 获取数据跳转表单 -->
<select id="findList" resultMap="policyMap">
SELECT
<include refid="policyColumns"/>
FROM
ip_reuse_policy_cfg r
<where>
<if test="cfgId != null">
AND r.cfg_id=#{cfgId,jdbcType=BIGINT}
</if>
<if test="isValid !=null">
AND r.is_valid = #{isValid,jdbcType=INTEGER}
</if>
<if test="isValid ==null">
AND r.is_valid != -1
</if>
<if test="isAudit !=null">
AND r.is_audit = #{isAudit,jdbcType=INTEGER}
</if>
</where>
ORDER BY r.cfg_id
</select>
<insert id="savePolicyCfg" parameterType="com.nis.domain.configuration.IpReusePolicyCfg">
INSERT INTO ip_reuse_policy_cfg (
cfg_desc,
addr_pool_id,
user_id,
user_type,
action,
is_valid,
is_audit,
cfg_type,
cfg_region_code,
function_id,
service_id,
compile_id,
is_area_effective,
area_effective_ids,
request_id,
classify,
attribute,
lable,
creator_id,
create_time,
editor_id,
edit_time,
auditor_id,
audit_time,
user_region1,
user_region2,
user_region3,
user_region4,
user_region5
)VALUES (
#{cfgDesc,jdbcType=VARCHAR},
#{addrPoolId,jdbcType=INTEGER},
#{userId,jdbcType=INTEGER},
#{userType,jdbcType=VARCHAR},
#{action,jdbcType=INTEGER},
0,
0,
#{cfgType,jdbcType=VARCHAR},
#{cfgRegionCode,jdbcType=INTEGER},
#{functionId,jdbcType=INTEGER},
#{serviceId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{isAreaEffective,jdbcType=INTEGER},
#{areaEffectiveIds,jdbcType=VARCHAR},
#{requestId,jdbcType=INTEGER},
#{classify,jdbcType=VARCHAR},
#{attribute,jdbcType=VARCHAR},
#{lable,jdbcType=VARCHAR},
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{auditorId,jdbcType=INTEGER},
#{auditTime,jdbcType=TIMESTAMP},
#{userRegion1,jdbcType=VARCHAR},
#{userRegion2,jdbcType=VARCHAR},
#{userRegion3,jdbcType=VARCHAR},
#{userRegion4,jdbcType=VARCHAR},
#{userRegion5,jdbcType=VARCHAR}
)
</insert>
<select id="getUserType" resultType="java.lang.String">
SELECT
user_type
FROM
user_manage
WHERE
id = #{userId}
</select>
<update id="updatePolicyCfg" parameterType="com.nis.domain.configuration.IpReusePolicyCfg">
update ip_reuse_policy_cfg
<set>
<trim suffixOverrides=",">
<if test="userId != null" >
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="userType != null and userType != ''" >
user_type = #{userType,jdbcType=VARCHAR},
</if>
<if test="addrPoolId != null" >
addr_pool_id = #{addrPoolId,jdbcType=INTEGER},
</if>
<if test="translateParam != null and translateParam != ''" >
translate_param = #{translateParam,jdbcType=VARCHAR},
</if>
<if test="userId != null" >
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="isValid != null" >
is_valid = #{isValid,jdbcType=INTEGER},
</if>
<if test="isAudit != null" >
is_audit = #{isAudit,jdbcType=INTEGER},
</if>
<if test="creatorId != null" >
creator_id = #{creatorId,jdbcType=INTEGER},
</if>
<if test="createTime != null and createTime != ''" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="editorId != null" >
editor_id = #{editorId,jdbcType=INTEGER},
</if>
<if test="editTime != null and editTime != ''" >
edit_time = #{editTime,jdbcType=TIMESTAMP},
</if>
<if test="auditorId != null" >
auditor_id = #{auditorId,jdbcType=INTEGER},
</if>
<if test="auditTime != null and createTime != ''" >
audit_time = #{auditTime,jdbcType=TIMESTAMP},
</if>
<if test="requestId != null" >
request_id = #{requestId,jdbcType=INTEGER},
</if>
<if test="isAreaEffective != null" >
is_area_effective = #{isAreaEffective,jdbcType=INTEGER},
</if>
<if test="classify != null and classify != ''" >
classify = #{classify,jdbcType=VARCHAR},
</if>
<if test="attribute != null and attribute != ''" >
attribute = #{attribute,jdbcType=VARCHAR},
</if>
<if test="lable != null and lable != ''" >
lable = #{lable,jdbcType=VARCHAR},
</if>
<if test="areaEffectiveIds != null" >
area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR},
</if>
</trim>
</set>
WHERE cfg_id = #{cfgId,jdbcType=BIGINT}
</update>
</mapper>