SNAT地址池管理提交.
This commit is contained in:
37
src/main/java/com/nis/domain/callback/IpAddrPool.java
Normal file
37
src/main/java/com/nis/domain/callback/IpAddrPool.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.nis.domain.callback;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
public class IpAddrPool extends InlineIp{
|
||||
|
||||
@Expose
|
||||
private Integer regionId;
|
||||
@Expose
|
||||
private Integer groupId;
|
||||
@Expose
|
||||
private Integer addrPoolId;
|
||||
|
||||
public Integer getRegionId() {
|
||||
return regionId;
|
||||
}
|
||||
|
||||
public void setRegionId(Integer regionId) {
|
||||
this.regionId = regionId;
|
||||
}
|
||||
|
||||
public Integer getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(Integer groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public Integer getAddrPoolId() {
|
||||
return addrPoolId;
|
||||
}
|
||||
|
||||
public void setAddrPoolId(Integer addrPoolId) {
|
||||
this.addrPoolId = addrPoolId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.nis.domain.configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* IP复用地址池实体
|
||||
* @author dell
|
||||
*
|
||||
*/
|
||||
public class IpAddrPoolCfg extends BaseCfg<IpAddrPoolCfg>{
|
||||
|
||||
private static final long serialVersionUID = 1392197458744667669L;
|
||||
private String indexTable="ip_reuse_addr_pool";
|
||||
|
||||
private Integer addrPoolId; // 地址池ID
|
||||
private String addrPoolName; // 地址池名称
|
||||
private Integer ipTotal; // IP总数
|
||||
private Integer availableIpTotal; // 可用IP总数
|
||||
private String description; // 描述信息
|
||||
|
||||
private List<BaseIpCfg> ipCfgs; // 地址池IP信息
|
||||
|
||||
@SerializedName("cfgId")
|
||||
private Integer compileId;
|
||||
|
||||
public String getIndexTable() {
|
||||
return indexTable;
|
||||
}
|
||||
public void setIndexTable(String indexTable) {
|
||||
this.indexTable = indexTable;
|
||||
}
|
||||
public Integer getAddrPoolId() {
|
||||
return addrPoolId;
|
||||
}
|
||||
public void setAddrPoolId(Integer addrPoolId) {
|
||||
this.addrPoolId = addrPoolId;
|
||||
}
|
||||
public String getAddrPoolName() {
|
||||
return addrPoolName;
|
||||
}
|
||||
public void setAddrPoolName(String addrPoolName) {
|
||||
this.addrPoolName = addrPoolName;
|
||||
}
|
||||
public Integer getIpTotal() {
|
||||
return ipTotal;
|
||||
}
|
||||
public void setIpTotal(Integer ipTotal) {
|
||||
this.ipTotal = ipTotal;
|
||||
}
|
||||
public Integer getAvailableIpTotal() {
|
||||
return availableIpTotal;
|
||||
}
|
||||
public void setAvailableIpTotal(Integer availableIpTotal) {
|
||||
this.availableIpTotal = availableIpTotal;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
public List<BaseIpCfg> getIpCfgs() {
|
||||
return ipCfgs;
|
||||
}
|
||||
public void setIpCfgs(List<BaseIpCfg> ipCfgs) {
|
||||
this.ipCfgs = ipCfgs;
|
||||
}
|
||||
public Integer getCompileId() {
|
||||
return compileId;
|
||||
}
|
||||
public void setCompileId(Integer compileId) {
|
||||
this.compileId = compileId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package com.nis.web.controller.configuration.maintenance;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.basics.PolicyGroupInfo;
|
||||
import com.nis.domain.configuration.IpAddrPoolCfg;
|
||||
import com.nis.domain.configuration.IpMultiplexPoolCfg;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.service.configuration.IpAddrPoolCfgService;
|
||||
|
||||
|
||||
/**
|
||||
* IP复用地址池配置
|
||||
* @author dell
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/maintenance/ipMultiplexPoolCfg")
|
||||
public class IpAddrPoolController extends BaseController{
|
||||
|
||||
@Autowired
|
||||
private IpAddrPoolCfgService ipAddrPoolCfgService;
|
||||
|
||||
@RequestMapping(value = {"/snatlist"})
|
||||
public String snatlist(Model model,HttpServletRequest request,HttpServletResponse response,
|
||||
@ModelAttribute("cfg")IpAddrPoolCfg entity){
|
||||
Page<IpAddrPoolCfg> page = ipAddrPoolCfgService.findPage(new Page<IpAddrPoolCfg>(request, response,"r"), entity);
|
||||
model.addAttribute("page", page);
|
||||
initFormCondition(model,entity);
|
||||
return "/cfg/maintenance/ipMultiplexPool/snatlist2";
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/snatform"})
|
||||
@RequiresPermissions(value={"ip:mulitiplex:pool:config"})
|
||||
public String snatfrom(Model model, String ids, HttpServletRequest request, HttpServletResponse response,
|
||||
@ModelAttribute("cfg")IpAddrPoolCfg cfg){
|
||||
if(cfg == null){
|
||||
cfg=new IpAddrPoolCfg();
|
||||
}
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
cfg = ipAddrPoolCfgService.getIpAddrPoolCfg(Long.valueOf(ids),null);
|
||||
PolicyGroupInfo groupInfo = policyGroupInfoService.getById(cfg.getAddrPoolId());
|
||||
cfg.setAddrPoolName(groupInfo.getGroupName());
|
||||
initUpdateFormCondition(model, cfg);
|
||||
}else{
|
||||
initFormCondition(model, cfg);
|
||||
}
|
||||
|
||||
model.addAttribute("_cfg", cfg);
|
||||
return "/cfg/maintenance/ipMultiplexPool/snatform2";
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/snatSaveOrUpdate"})
|
||||
@RequiresPermissions(value={"ip:mulitiplex:pool:config"})
|
||||
public String snatSaveOrUpdate(Model model,HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirectAttributes,
|
||||
@ModelAttribute("cfg")IpAddrPoolCfg cfg){
|
||||
try{
|
||||
// 保存地址池信息 -> policy_group_info
|
||||
PolicyGroupInfo entity = new PolicyGroupInfo();
|
||||
if(cfg.getAddrPoolId() != null){
|
||||
entity.setGroupId(cfg.getAddrPoolId());
|
||||
}
|
||||
entity.setGroupType(2);
|
||||
entity.setGroupName(cfg.getAddrPoolName());
|
||||
entity.setDescription(cfg.getDescription());
|
||||
policyGroupInfoService.saveOrUpdate(entity);
|
||||
cfg.setAddrPoolId(policyGroupInfoService.getGroupIdByGroupName(cfg.getAddrPoolName()));
|
||||
|
||||
ipAddrPoolCfgService.saveOrUpdate(cfg, request, response);
|
||||
addMessage(redirectAttributes,"success","save_success");
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
if(e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes,"error", "request_service_failed");
|
||||
}else {
|
||||
addMessage(redirectAttributes,"error", "save_failed");
|
||||
}
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath +"/maintenance/ipMultiplexPoolCfg/snatlist?functionId="+cfg.getFunctionId();
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/snatAudit"})
|
||||
@RequiresPermissions(value={"ip:mulitiplex:pool:confirm"})
|
||||
public String snataudit(Integer isAudit,Integer isValid,String ids,Integer functionId,RedirectAttributes redirectAttributes) {
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
String[] idArray = ids.split(",");
|
||||
Date auditTime=new Date();
|
||||
for(String id :idArray){
|
||||
try {
|
||||
ipAddrPoolCfgService.audit(isAudit,isValid,functionId,id,auditTime);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("SNAT地址池配置下发失败:"+e.getMessage());
|
||||
if(e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes,"error", "request_service_failed");
|
||||
}else {
|
||||
addMessage(redirectAttributes,"error", "audit_failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return "redirect:" + adminPath +"/maintenance/ipMultiplexPoolCfg/snatlist?functionId="+functionId;
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/snatDelete"})
|
||||
@RequiresPermissions(value={"ip:mulitiplex:pool:config"})
|
||||
public String snatdelete(Integer isAudit,Integer isValid,String ids,Integer functionId,Model model,RedirectAttributes redirectAttributes
|
||||
,HttpServletRequest request,HttpServletResponse response){
|
||||
try{
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
// ?未被任何策略引用的地址池可删除
|
||||
ipAddrPoolCfgService.delete(isAudit,isValid,ids,functionId);
|
||||
}
|
||||
addMessage(redirectAttributes,"success","delete_success");
|
||||
}catch(Exception e){
|
||||
logger.error(e);
|
||||
addMessage(redirectAttributes,"error","delete_failed");
|
||||
}
|
||||
return "redirect:" + adminPath +"/maintenance/ipMultiplexPoolCfg/snatlist?functionId="+functionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验地址池
|
||||
* @param cfg
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value = {"/checkAddrPool"})
|
||||
public boolean checkAddrPool(IpAddrPoolCfg cfg, HttpServletRequest request, HttpServletResponse response){
|
||||
// 修改
|
||||
if(!StringUtil.isEmpty(cfg.getCfgId())){
|
||||
IpAddrPoolCfg poolCfg = ipAddrPoolCfgService.getCfgInfo(cfg);
|
||||
if(poolCfg != null && poolCfg.getAddrPoolName().equals(cfg.getAddrPoolName())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
cfg.setCfgId(null);
|
||||
IpAddrPoolCfg poolCfg = ipAddrPoolCfgService.getCfgInfo(cfg);
|
||||
if(poolCfg != null){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public class IpMultiplexPoolCfgController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = {"/snatlist"})
|
||||
/*@RequestMapping(value = {"/snatlist"})
|
||||
public String snatlist(Model model,HttpServletRequest request,HttpServletResponse response,@ModelAttribute("cfg")IpMultiplexPoolCfg entity){
|
||||
//查询时left join policyGroup
|
||||
Page<IpMultiplexPoolCfg> page = ipMultiplexPoolCfgService.findPage(new Page<IpMultiplexPoolCfg>(request, response,"r"), entity);
|
||||
@@ -236,7 +236,7 @@ public class IpMultiplexPoolCfgController extends BaseController {
|
||||
addMessage(redirectAttributes,"error","delete_failed");
|
||||
}
|
||||
return "redirect:" + adminPath +"/maintenance/ipMultiplexPoolCfg/snatlist?functionId="+functionId;
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 校验IP是否已存在
|
||||
|
||||
@@ -20,4 +20,7 @@ public interface PolicyGroupInfoDao extends CrudDao<PolicyGroupInfo> {
|
||||
PolicyGroupInfo getInfoByAsnNo(PolicyGroupInfo policyGroupInfo);
|
||||
List<PolicyGroupInfo> getHasAreaPolicyGroups(int groupType);
|
||||
int insertBatch(List<PolicyGroupInfo> list);
|
||||
|
||||
Integer getGroupIdByGroupName(String groupName);
|
||||
PolicyGroupInfo getGroupInfo(PolicyGroupInfo policyGroupInfo);
|
||||
}
|
||||
@@ -213,4 +213,37 @@
|
||||
SELECT ga.group_id FROM group_area_info ga WHERE ga.is_valid != -1
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="getGroupIdByGroupName" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
r.group_id
|
||||
FROM
|
||||
policy_group_info r
|
||||
WHERE
|
||||
r.group_name = #{groupName}
|
||||
</select>
|
||||
|
||||
<select id="getGroupInfo" resultType="com.nis.domain.basics.PolicyGroupInfo">
|
||||
SELECT
|
||||
<include refid="PolicyGroupInfoColumns"/>
|
||||
FROM
|
||||
policy_group_info r
|
||||
<trim prefix="WHERE" prefixOverrides="AND |OR ">
|
||||
<if test="groupName != null and groupName != ''" >
|
||||
AND group_name = #{groupName,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="groupType != null" >
|
||||
AND group_type = #{groupType,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="asnNo != null" >
|
||||
AND asn_no = #{asnNo,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="isValid != null" >
|
||||
AND is_valid = #{isValid,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="isValid == null" >
|
||||
AND is_valid != -1
|
||||
</if>
|
||||
</trim>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.nis.web.dao.configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.IpAddrPoolCfg;
|
||||
import com.nis.web.dao.CrudDao;
|
||||
import com.nis.web.dao.MyBatisDao;
|
||||
|
||||
@MyBatisDao
|
||||
public interface IpAddrPoolCfgDao extends CrudDao<IpAddrPoolCfgDao>{
|
||||
|
||||
List<IpAddrPoolCfg> findPage(IpAddrPoolCfg entity);
|
||||
|
||||
List<IpAddrPoolCfg> findList(@Param("cfgId")Long cfgId
|
||||
,@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);
|
||||
|
||||
IpAddrPoolCfg getCfgInfo(IpAddrPoolCfg cfg);
|
||||
|
||||
}
|
||||
442
src/main/java/com/nis/web/dao/configuration/IpAddrPoolCfgDao.xml
Normal file
442
src/main/java/com/nis/web/dao/configuration/IpAddrPoolCfgDao.xml
Normal file
@@ -0,0 +1,442 @@
|
||||
<?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.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"/>
|
||||
<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" />
|
||||
<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="description" property="description" jdbcType="VARCHAR"/>
|
||||
<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="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_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.DESCRIPTION,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>
|
||||
|
||||
<sql id="IpCfg_Column" >
|
||||
a.cfg_id,a.cfg_desc,a.ip_type,a.src_ip_address,a.ip_pattern,a.port_pattern,a.src_port
|
||||
,a.protocol,a.protocol_id,a.direction,a.cfg_type,a.action,a.dest_port,a.dest_ip_address
|
||||
,a.is_valid,a.is_audit,a.creator_id,a.create_time,a.editor_id
|
||||
,a.edit_time,a.auditor_id,a.audit_time,a.service_id,a.request_id,
|
||||
a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable
|
||||
,a.area_effective_ids,a.function_id,a.cfg_region_code
|
||||
</sql>
|
||||
|
||||
<select id="findPage" resultMap="addrPoolMap">
|
||||
SELECT
|
||||
<include refid="addrPoolColumns"/>
|
||||
<trim prefix="," prefixOverrides=",">
|
||||
,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
|
||||
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="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}
|
||||
</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>
|
||||
<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="addrPoolMap">
|
||||
SELECT
|
||||
<include refid="addrPoolColumns"/>
|
||||
FROM
|
||||
ip_reuse_addr_pool r
|
||||
<where>
|
||||
<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="cfgId != null">
|
||||
AND r.cfg_id = #{cfgId,jdbcType=BIGINT}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY cfg_Id
|
||||
</select>
|
||||
|
||||
<!-- 保存地址池IP信息 -->
|
||||
<insert id="saveReuseIpCfgs" parameterType="com.nis.domain.configuration.BaseIpCfg">
|
||||
INSERT INTO ip_reuse_ip_cfg (
|
||||
CFG_DESC,
|
||||
ACTION,
|
||||
IS_VALID,
|
||||
IS_AUDIT,
|
||||
CREATOR_ID,
|
||||
CREATE_TIME,
|
||||
EDITOR_ID,
|
||||
EDIT_TIME,
|
||||
AUDITOR_ID,
|
||||
AUDIT_TIME,
|
||||
SERVICE_ID,
|
||||
REQUEST_ID,
|
||||
COMPILE_ID,
|
||||
IS_AREA_EFFECTIVE,
|
||||
CLASSIFY,
|
||||
ATTRIBUTE,
|
||||
LABLE,
|
||||
AREA_EFFECTIVE_IDS,
|
||||
function_id,
|
||||
ip_type,
|
||||
src_ip_address,
|
||||
ip_pattern,
|
||||
port_pattern,
|
||||
src_port,
|
||||
protocol,
|
||||
protocol_id,
|
||||
direction,
|
||||
dest_port,
|
||||
dest_ip_address,
|
||||
cfg_type,
|
||||
cfg_region_code,
|
||||
user_region1,
|
||||
user_region2,
|
||||
user_region3,
|
||||
user_region4,
|
||||
user_region5
|
||||
)VALUES (
|
||||
#{cfgDesc,jdbcType=VARCHAR},
|
||||
#{action,jdbcType=INTEGER},
|
||||
0,
|
||||
0,
|
||||
#{creatorId,jdbcType=INTEGER},
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
#{editorId,jdbcType=INTEGER},
|
||||
#{editTime,jdbcType=TIMESTAMP},
|
||||
#{auditorId,jdbcType=INTEGER},
|
||||
#{auditTime,jdbcType=TIMESTAMP},
|
||||
#{serviceId,jdbcType=INTEGER},
|
||||
#{requestId,jdbcType=INTEGER},
|
||||
#{compileId,jdbcType=INTEGER},
|
||||
#{isAreaEffective,jdbcType=INTEGER},
|
||||
#{classify,jdbcType=VARCHAR},
|
||||
#{attribute,jdbcType=VARCHAR},
|
||||
#{lable,jdbcType=VARCHAR},
|
||||
#{areaEffectiveIds,jdbcType=VARCHAR},
|
||||
#{functionId,jdbcType=INTEGER},
|
||||
#{ipType,jdbcType=INTEGER},
|
||||
#{srcIpAddress,jdbcType=VARCHAR},
|
||||
#{ipPattern,jdbcType=INTEGER},
|
||||
#{portPattern,jdbcType=INTEGER},
|
||||
#{srcPort,jdbcType=VARCHAR},
|
||||
#{protocol,jdbcType=INTEGER},
|
||||
#{protocolId,jdbcType=INTEGER},
|
||||
#{direction,jdbcType=INTEGER},
|
||||
#{destPort,jdbcType=VARCHAR},
|
||||
#{destIpAddress,jdbcType=VARCHAR},
|
||||
#{cfgType,jdbcType=VARCHAR},
|
||||
#{cfgRegionCode,jdbcType=INTEGER},
|
||||
#{userRegion1,jdbcType=VARCHAR},
|
||||
#{userRegion2,jdbcType=VARCHAR},
|
||||
#{userRegion3,jdbcType=VARCHAR},
|
||||
#{userRegion4,jdbcType=VARCHAR},
|
||||
#{userRegion5,jdbcType=VARCHAR}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<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,
|
||||
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,
|
||||
description,
|
||||
user_region1,
|
||||
user_region2,
|
||||
user_region3,
|
||||
user_region4,
|
||||
user_region5
|
||||
)VALUES (
|
||||
#{addrPoolId,jdbcType=INTEGER},
|
||||
#{addrPoolName,jdbcType=VARCHAR},
|
||||
#{ipTotal,jdbcType=INTEGER},
|
||||
#{availableIpTotal,jdbcType=INTEGER},
|
||||
#{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},
|
||||
#{description,jdbcType=VARCHAR},
|
||||
#{userRegion1,jdbcType=VARCHAR},
|
||||
#{userRegion2,jdbcType=VARCHAR},
|
||||
#{userRegion3,jdbcType=VARCHAR},
|
||||
#{userRegion4,jdbcType=VARCHAR},
|
||||
#{userRegion5,jdbcType=VARCHAR}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="getReuseIpCfgs" resultType="com.nis.domain.configuration.BaseIpCfg">
|
||||
SELECT
|
||||
<include refid="IpCfg_Column" />
|
||||
FROM
|
||||
ip_reuse_ip_cfg a
|
||||
WHERE
|
||||
a.is_valid != -1 AND a.user_region1 = #{addrPoolId}
|
||||
</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>
|
||||
|
||||
<delete id="deleteReuseIpCfgs" parameterType="java.lang.Integer">
|
||||
DELETE FROM ip_reuse_ip_cfg WHERE user_region1 = #{addrPoolId}
|
||||
</delete>
|
||||
|
||||
<update id="updateAddrPoolCfg" parameterType="com.nis.domain.configuration.IpAddrPoolCfg">
|
||||
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>
|
||||
<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="serviceId != null" >
|
||||
service_id = #{serviceId,jdbcType=INTEGER},
|
||||
</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>
|
||||
<if test="functionId != null" >
|
||||
function_id = #{functionId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="description != null and description != ''" >
|
||||
description = #{description,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</set>
|
||||
where cfg_id = #{cfgId,jdbcType=BIGINT}
|
||||
|
||||
</update>
|
||||
|
||||
<select id="getCfgInfo" parameterType="com.nis.domain.configuration.IpAddrPoolCfg" resultMap="addrPoolMap">
|
||||
SELECT
|
||||
<include refid="addrPoolColumns"/>
|
||||
FROM ip_reuse_addr_pool r
|
||||
<trim prefix="WHERE" prefixOverrides="AND |OR ">
|
||||
<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="functionId != null">
|
||||
AND r.function_id=#{functionId,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="addrPoolName != null and addrPoolName != ''">
|
||||
AND r.addr_pool_name = #{addrPoolName,jdbcType=VARCHAR}
|
||||
</if>
|
||||
</trim>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.IpMultiplexPoolCfg;
|
||||
import com.nis.web.dao.CrudDao;
|
||||
import com.nis.web.dao.MyBatisDao;
|
||||
@@ -19,4 +20,7 @@ public interface IpMultiplexPoolCfgDao extends CrudDao<IpMultiplexPoolCfg> {
|
||||
|
||||
List<IpMultiplexPoolCfg> getIspByGroupId(Integer groupId);
|
||||
|
||||
// 保存IP信息
|
||||
void saveReuseIps(BaseIpCfg ipCfg);
|
||||
|
||||
}
|
||||
@@ -44,7 +44,50 @@
|
||||
,r.is_area_effective,r.classify,r.attribute,r.lable
|
||||
,r.area_effective_ids,r.function_id,r.cfg_region_code,r.compile_id
|
||||
</sql>
|
||||
|
||||
|
||||
<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"/>
|
||||
<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" />
|
||||
<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="description" property="description" jdbcType="VARCHAR"/>
|
||||
<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="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_REGION_CODE,r.CFG_TYPE,r.FUNCTION_ID,r.SERVICE_ID,r.COMPILE_ID,r.REQUEST_ID,
|
||||
r.CLASSIFY,r.ATTRIBUTE,r.LABLE,r.IS_AREA_EFFECTIVE,r.AREA_EFFECTIVE_IDS,
|
||||
r.CREATOR_ID,r.CREATE_TIME,r.EDITOR_ID,r.EDIT_TIME,r.AUDITOR_ID,r.AUDIT_TIME,
|
||||
r.DESCRIPTION,r.CANCEL_REQUEST_ID,
|
||||
r.USER_REGION1,r.USER_REGION2,r.USER_REGION3,r.USER_REGION4,r.USER_REGION5
|
||||
</sql>
|
||||
|
||||
<!-- 查出所有 有效数据-->
|
||||
<select id="findPage" resultMap="IpMultiplexPoolCfgMap">
|
||||
SELECT
|
||||
@@ -54,7 +97,7 @@
|
||||
,ri.request_title as requestName
|
||||
</trim>
|
||||
FROM ip_multiplex_pool_cfg r
|
||||
left join policy_group_info a on r.policy_group=a.group_Id
|
||||
<!-- left join policy_group_info a on r.policy_group=a.group_Id -->
|
||||
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
|
||||
@@ -337,4 +380,82 @@
|
||||
r.POLICY_GROUP = #{groupId} AND r.IS_VALID != -1
|
||||
|
||||
</select>
|
||||
|
||||
<insert id="saveReuseIps" parameterType="com.nis.domain.configuration.BaseIpCfg" >
|
||||
insert into ip_reuse_ip_cfg (
|
||||
CFG_DESC,
|
||||
ACTION,
|
||||
IS_VALID,
|
||||
IS_AUDIT,
|
||||
CREATOR_ID,
|
||||
CREATE_TIME,
|
||||
EDITOR_ID,
|
||||
EDIT_TIME,
|
||||
AUDITOR_ID,
|
||||
AUDIT_TIME,
|
||||
SERVICE_ID,
|
||||
REQUEST_ID,
|
||||
COMPILE_ID,
|
||||
IS_AREA_EFFECTIVE,
|
||||
CLASSIFY,
|
||||
ATTRIBUTE,
|
||||
LABLE,
|
||||
AREA_EFFECTIVE_IDS,
|
||||
function_id,
|
||||
ip_type,
|
||||
src_ip_address,
|
||||
ip_pattern,
|
||||
port_pattern,
|
||||
src_port,
|
||||
protocol,
|
||||
protocol_id,
|
||||
direction,
|
||||
dest_port,
|
||||
dest_ip_address,
|
||||
cfg_type,
|
||||
cfg_region_code,
|
||||
user_region1,
|
||||
user_region2,
|
||||
user_region3,
|
||||
user_region4,
|
||||
user_region5
|
||||
)values (
|
||||
#{cfgDesc,jdbcType=VARCHAR},
|
||||
#{action,jdbcType=INTEGER},
|
||||
0,
|
||||
0,
|
||||
#{creatorId,jdbcType=INTEGER},
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
#{editorId,jdbcType=INTEGER},
|
||||
#{editTime,jdbcType=TIMESTAMP},
|
||||
#{auditorId,jdbcType=INTEGER},
|
||||
#{auditTime,jdbcType=TIMESTAMP},
|
||||
#{serviceId,jdbcType=INTEGER},
|
||||
#{requestId,jdbcType=INTEGER},
|
||||
#{compileId,jdbcType=INTEGER},
|
||||
#{isAreaEffective,jdbcType=INTEGER},
|
||||
#{classify,jdbcType=VARCHAR},
|
||||
#{attribute,jdbcType=VARCHAR},
|
||||
#{lable,jdbcType=VARCHAR},
|
||||
#{areaEffectiveIds,jdbcType=VARCHAR},
|
||||
#{functionId,jdbcType=INTEGER},
|
||||
#{ipType,jdbcType=INTEGER},
|
||||
#{srcIpAddress,jdbcType=VARCHAR},
|
||||
#{ipPattern,jdbcType=INTEGER},
|
||||
#{portPattern,jdbcType=INTEGER},
|
||||
#{srcPort,jdbcType=VARCHAR},
|
||||
#{protocol,jdbcType=INTEGER},
|
||||
#{protocolId,jdbcType=INTEGER},
|
||||
#{direction,jdbcType=INTEGER},
|
||||
#{destPort,jdbcType=VARCHAR},
|
||||
#{destIpAddress,jdbcType=VARCHAR},
|
||||
#{cfgType,jdbcType=VARCHAR},
|
||||
#{cfgRegionCode,jdbcType=INTEGER},
|
||||
#{userRegion1,jdbcType=VARCHAR},
|
||||
#{userRegion2,jdbcType=VARCHAR},
|
||||
#{userRegion3,jdbcType=VARCHAR},
|
||||
#{userRegion4,jdbcType=VARCHAR},
|
||||
#{userRegion5,jdbcType=VARCHAR}
|
||||
)
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -15,4 +15,6 @@ public interface UserManageDao extends CrudDao<UserManage>{
|
||||
UserManage getUserByLoginName(@Param("userName") String userName);
|
||||
List<UserManage> findList(UserManage entity);
|
||||
UserManage getUserById(@Param("id") String id);
|
||||
|
||||
List<UserManage> findUsers();
|
||||
}
|
||||
|
||||
@@ -151,4 +151,10 @@
|
||||
<include refid="Columns"/>
|
||||
from user_manage r where r.is_valid !=-1 and r.id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="findUsers" resultMap="userManageMap">
|
||||
select
|
||||
<include refid="Columns"/>
|
||||
from user_manage r where r.is_valid !=-1
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -160,4 +160,13 @@ public class PolicyGroupInfoService extends BaseService{
|
||||
public List<PolicyGroupInfo> getHasAreaPolicyGroups(int groupType) {
|
||||
return policyGroupInfoDao.getHasAreaPolicyGroups(groupType);
|
||||
}
|
||||
|
||||
public Integer getGroupIdByGroupName(String groupName){
|
||||
return policyGroupInfoDao.getGroupIdByGroupName(groupName);
|
||||
}
|
||||
|
||||
public PolicyGroupInfo getGroupInfo(PolicyGroupInfo policyGroupInfo){
|
||||
return policyGroupInfoDao.getGroupInfo(policyGroupInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,285 @@
|
||||
package com.nis.web.service.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.beust.jcommander.internal.Lists;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.callback.InlineIp;
|
||||
import com.nis.domain.callback.IpAddrPool;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.IpAddrPoolCfg;
|
||||
import com.nis.domain.configuration.IpMultiplexPoolCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.domain.maat.MaatCfg.IpCfg;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
import com.nis.web.dao.configuration.IpAddrPoolCfgDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
import com.nis.web.service.BaseService;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
import com.nis.web.service.basics.PolicyGroupInfoService;
|
||||
|
||||
import jersey.repackaged.com.google.common.collect.Maps;
|
||||
|
||||
@Service
|
||||
public class IpAddrPoolCfgService extends BaseService{
|
||||
|
||||
@Autowired
|
||||
private IpAddrPoolCfgDao ipAddrPoolCfgDao;
|
||||
|
||||
/**
|
||||
* 列表分页查询
|
||||
* @param page
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<IpAddrPoolCfg> findPage(Page<IpAddrPoolCfg> page, IpAddrPoolCfg entity) {
|
||||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r"));
|
||||
entity.setPage(page);
|
||||
List<IpAddrPoolCfg> list=ipAddrPoolCfgDao.findPage(entity);
|
||||
page.setList(list);
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据跳转表单
|
||||
* @param id
|
||||
* @param isValid
|
||||
* @return
|
||||
*/
|
||||
public IpAddrPoolCfg getIpAddrPoolCfg(Long id, Integer isValid) {
|
||||
// 1.获取地址池配置信息
|
||||
List<IpAddrPoolCfg> list=ipAddrPoolCfgDao.findList(id,isValid,null);
|
||||
IpAddrPoolCfg addrPoolCfg=null;
|
||||
if(list != null && list.size()>0){
|
||||
addrPoolCfg=list.get(0);
|
||||
}
|
||||
|
||||
// 2.获取地址池内IP信息
|
||||
List<BaseIpCfg> ipCfgs = ipAddrPoolCfgDao.getReuseIpCfgs(addrPoolCfg.getAddrPoolId());
|
||||
if(ipCfgs != null && ipCfgs.size()>0){
|
||||
addrPoolCfg.setIpCfgs(ipCfgs);
|
||||
}
|
||||
return addrPoolCfg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新配置数据
|
||||
* @param res
|
||||
* @param req
|
||||
* @param cfg
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveOrUpdate(IpAddrPoolCfg entity, HttpServletRequest req, HttpServletResponse res) {
|
||||
|
||||
// 可用IP数(需调用CGI接口查询)
|
||||
/*Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("cmd", "IpNumGet");
|
||||
params.put("addr_pool_id", entity.getAddrPoolId());
|
||||
try {
|
||||
String resJson = HttpClientUtil.getMsg("", params, req);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}*/
|
||||
|
||||
// 1.更新配置信息
|
||||
Date time = new Date();
|
||||
entity.setIsValid(0);
|
||||
entity.setIsAudit(0);
|
||||
setAreaEffectiveIds(entity);
|
||||
entity.setIpTotal(entity.getIpCfgs().size());
|
||||
if(entity.getCfgId()==null){
|
||||
entity.initDefaultValue();
|
||||
entity.setCreateTime(time);
|
||||
entity.setCreatorId(UserUtils.getUser().getId());
|
||||
//调用服务接口获取compileId
|
||||
try {
|
||||
List<Integer> compileIds = ConfigServiceUtil.getId(1,1);
|
||||
if(compileIds != null && compileIds.size() > 0 ){
|
||||
entity.setCompileId(compileIds.get(0));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("获取编译ID出错");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
ipAddrPoolCfgDao.saveAddrPoolCfg(entity);
|
||||
|
||||
}else{
|
||||
entity.setEditorId(UserUtils.getUser().getId());
|
||||
entity.setEditTime(time);
|
||||
ipAddrPoolCfgDao.updateAddrPoolCfg(entity);
|
||||
entity.setCreateTime(new Date());
|
||||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||||
}
|
||||
ipAddrPoolCfgDao.deleteReuseIpCfgs(entity.getAddrPoolId());
|
||||
|
||||
// 2.保存IP信息 -> ip_reuse_ip_cfg(该表user_region1字段 存放 地址池ID)
|
||||
for (BaseIpCfg IpCfg : entity.getIpCfgs()) {
|
||||
BeanUtils.copyProperties(entity, IpCfg);
|
||||
IpCfg.setUserRegion1(entity.getAddrPoolId()+"");
|
||||
ipAddrPoolCfgDao.saveReuseIpCfgs(IpCfg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void delete(Integer isAudit, Integer isValid, String ids, Integer functionId) {
|
||||
String[] idArray = ids.split(",");
|
||||
String groupIds = "";
|
||||
for(String id :idArray){
|
||||
IpAddrPoolCfg entity = new IpAddrPoolCfg();
|
||||
entity.setCfgId(Long.valueOf(id));
|
||||
entity.setFunctionId(functionId);
|
||||
entity.setIsAudit(isAudit);
|
||||
entity.setIsValid(isValid);
|
||||
entity.setEditorId(UserUtils.getUser().getId());
|
||||
entity.setEditTime(new Date());
|
||||
Integer addrPoolId = ipAddrPoolCfgDao.getAddrPoolId(entity.getCfgId());
|
||||
groupIds += addrPoolId+",";
|
||||
ipAddrPoolCfgDao.deleteReuseIpCfgs(addrPoolId);
|
||||
|
||||
ipAddrPoolCfgDao.updateAddrPoolCfg(entity);
|
||||
|
||||
}
|
||||
PolicyGroupInfoService groupInfoService = SpringContextHolder.getBean(PolicyGroupInfoService.class);
|
||||
groupInfoService.deldete(groupIds, isValid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置审核
|
||||
* @param isAudit
|
||||
* @param isValid
|
||||
* @param functionId
|
||||
* @param id
|
||||
* @param auditTime
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void audit(Integer isAudit, Integer isValid, Integer functionId, String id, Date auditTime) {
|
||||
IpAddrPoolCfg cfg=new IpAddrPoolCfg();
|
||||
cfg.setCfgId(Long.valueOf(id));
|
||||
cfg.setIsValid(isValid);
|
||||
cfg.setIsAudit(isAudit);
|
||||
cfg.setAuditorId(UserUtils.getUser().getId());
|
||||
cfg.setAuditTime(auditTime);
|
||||
ipAddrPoolCfgDao.updateAddrPoolCfg(cfg);// 更新配置审核状态
|
||||
|
||||
cfg=getIpAddrPoolCfg(cfg.getCfgId(), null);
|
||||
String json="";
|
||||
if(cfg.getIsAudit()==1){
|
||||
List<IpAddrPool> resStrategyList=new ArrayList<IpAddrPool>();
|
||||
for(BaseIpCfg ipcfg : cfg.getIpCfgs()) {
|
||||
IpAddrPool ip = new IpAddrPool();
|
||||
BeanUtils.copyProperties(cfg, ipcfg, new String[]{"cfgId"});
|
||||
List<IpCfg> cfgs = BaseService.ipConvert(new IpCfg(), ipcfg);
|
||||
if (cfgs.size() > 1) {
|
||||
throw new RuntimeException("CallBack IP did not support IP range!");
|
||||
}
|
||||
IpCfg c = cfgs.get(0);
|
||||
ip.setRegionId(ipcfg.getCompileId());
|
||||
//ip.setGroupId(ipcfg.getCompileId());
|
||||
|
||||
ip.setAddrType(ipcfg.getIpType());
|
||||
ip.setSrcIp(c.getSrcIp());
|
||||
ip.setMaskSrcIp(c.getSrcIpMask());
|
||||
ip.setSrcPort(c.getSrcPort());
|
||||
ip.setMaskSrcPort(c.getSrcPortMask());
|
||||
ip.setDstIp(c.getDstIp());
|
||||
ip.setMaskDstIp(c.getDstIpMask());
|
||||
ip.setDstPort(c.getDstPort());
|
||||
ip.setMaskDstPort(c.getDstPortMask());
|
||||
ip.setProtocol(ipcfg.getProtocol());
|
||||
ip.setDirection(ipcfg.getDirection());
|
||||
|
||||
ip.setIsValid(cfg.getIsValid());
|
||||
ip.setAction(ipcfg.getAction());
|
||||
ip.setService(ipcfg.getServiceId());
|
||||
ip.setAddrPoolId(cfg.getAddrPoolId());
|
||||
ip.setOpTime(auditTime);
|
||||
ip.setAreaEffectiveIds(cfg.getAreaEffectiveIds());//添加区域管控
|
||||
|
||||
resStrategyList.add(ip);
|
||||
}
|
||||
//调用服务接口下发配置数据
|
||||
json=gsonToJson(resStrategyList);
|
||||
logger.info("SNAT地址池配置下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json);
|
||||
if(result!=null){
|
||||
logger.info("SNAT地址池配置下发响应信息:"+result.getMsg());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("SNAT地址池配置下发失败",e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}else if(cfg.getIsAudit()==3){
|
||||
List<IpAddrPool> resStrategyList=new ArrayList<IpAddrPool>();
|
||||
for(BaseIpCfg ipcfg : cfg.getIpCfgs()) {
|
||||
IpAddrPool ip = new IpAddrPool();
|
||||
BeanUtils.copyProperties(cfg, ipcfg, new String[]{"cfgId"});
|
||||
List<IpCfg> cfgs = BaseService.ipConvert(new IpCfg(), ipcfg);
|
||||
if (cfgs.size() > 1) {
|
||||
throw new RuntimeException("CallBack IP did not support IP range!");
|
||||
}
|
||||
IpCfg c = cfgs.get(0);
|
||||
ip.setRegionId(ipcfg.getCompileId());
|
||||
ip.setAddrType(ipcfg.getIpType());
|
||||
ip.setSrcIp(c.getSrcIp());
|
||||
ip.setMaskSrcIp(c.getSrcIpMask());
|
||||
ip.setSrcPort(c.getSrcPort());
|
||||
ip.setMaskSrcPort(c.getSrcPortMask());
|
||||
ip.setDstIp(c.getDstIp());
|
||||
ip.setMaskDstIp(c.getDstIpMask());
|
||||
ip.setDstPort(c.getDstPort());
|
||||
ip.setMaskDstPort(c.getDstPortMask());
|
||||
ip.setProtocol(ipcfg.getProtocol());
|
||||
ip.setDirection(ipcfg.getDirection());
|
||||
ip.setIsValid(cfg.getIsValid());
|
||||
ip.setAction(ipcfg.getAction());
|
||||
ip.setService(ipcfg.getServiceId());
|
||||
ip.setAddrPoolId(cfg.getAddrPoolId());
|
||||
ip.setOpTime(auditTime);
|
||||
ip.setAreaEffectiveIds(cfg.getAreaEffectiveIds());
|
||||
resStrategyList.add(ip);
|
||||
}
|
||||
//调用服务接口取消配置
|
||||
json=gsonToJson(resStrategyList);
|
||||
logger.info("SNAT地址池配置配置参数:"+json);
|
||||
//调用服务接口取消配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.put(json, 2);
|
||||
logger.info("SNAT地址池配置响应信息:"+result.getMsg());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("SNAT地址池配置配置失败");
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IpAddrPoolCfg getCfgInfo(IpAddrPoolCfg cfg) {
|
||||
return ipAddrPoolCfgDao.getCfgInfo(cfg);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -181,4 +181,7 @@ public class UserManageService extends BaseService{
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<UserManage> findUsers() {
|
||||
return userManageDao.findUsers();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user